Skip to content

Instantly share code, notes, and snippets.

@YannBouyeron
Last active April 8, 2022 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save YannBouyeron/5ed34d3b107381430099d0b901a6e21c to your computer and use it in GitHub Desktop.
Save YannBouyeron/5ed34d3b107381430099d0b901a6e21c to your computer and use it in GitHub Desktop.
Envoyer un mail avec python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def sendmail(_from, _to, _sujet, _mess, _mdp):
msg = MIMEMultipart()
msg['From'] = _from
msg['To'] = _to
msg['Subject'] = _sujet
message = _mess
msg.attach(MIMEText(message))
mailserver = smtplib.SMTP('smtp.live.com', 25) # a adapter selon votre boite mail
mailserver.ehlo()
mailserver.starttls()
mailserver.ehlo()
mailserver.login(_from, _mdp)
mailserver.sendmail(_from , _to , msg.as_string())
mailserver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment