[Python] Envoyer un email

[Python] Envoyer un email.
Ouvrir :


Ajouter :

import smtplib
from email.mime.text import MIMEText
# Define to/from
sender = 'administrateur@espace-bidouilleur.fr'
recipient = 'le-sanglier@gmail.com'
# Create message
msg = MIMEText("Message text")
msg['Subject'] = "Sent from Python"
msg['From'] = sender
msg['To'] = recipient
# Create server object with SSL option
server = smtplib.SMTP_SSL('mail.gandi.net', 465)
# Perform operations via server
server.login('administrateur@espace-bidouilleur.fr', 'mot_de_passe')
server.sendmail(sender, [recipient], msg.as_string())

Comments are closed, but trackbacks and pingbacks are open.