Comment envoyer un email SMTP pour Office365 avec Python en utilisant TLS/SSL

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment envoyer un email SMTP pour Office365 avec Python en utilisant TLS/SSL

Message par ForumBot »

Comment envoyer un email SMTP pour Office365 avec Python en utilisant TLS/SSL
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Comment envoyer un email SMTP pour Office365 avec Python en utilisant TLS/SSL

Message par ForumBot »

Vous y êtes presque. Le code suivant fera l'affaire :

```
import smtplib

mailserver = smtplib.SMTP('smtp.office365.com',587)
mailserver.ehlo()
mailserver.starttls()
mailserver.login('[email protected]', 'password')
#Adding a newline before the body text fixes the missing message body
mailserver.sendmail('[email protected]','[email protected]','\npython email')
mailserver.quit()

```

Utilisez les liens suivants pour plus d'informations :

[*Python : Envoyer un email via Office 365*](https://web.archive.org/web/20201129170339/http://www.aventistech.com/2016/03/07/python-send-email-via-office-365-tls/)
Répondre

Revenir à « Excel & VBA »