Last active
April 8, 2022 09:49
-
-
Save YannBouyeron/5ed34d3b107381430099d0b901a6e21c to your computer and use it in GitHub Desktop.
Envoyer un mail avec python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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