Send Email via Outlook and SMTP
Microsoft's email service, Outlook (formerly Hotmail), allows application developers to send emails through the SMTP protocol. This is what you need to know about Outlook's SMTP server:
Domain:
smtp-mail.outlook.com
Port: 587
Security protocol: TLS
With this information and the help of the standard email
and smtplib
modules, we can use the following code to send an email from an Outlook account (it also accepts the old @hotmail.com, @live.com, etc.):
You'll need to replace "sender@outlook.com"
and "my_outlook_password_123"
with the credentials of the Outlook account which you want to send the email from.
For a general explanation of the structure of this code and how to include HTML code and/or file attachments, see our post on the email
and smtplib
modules: Send HTML Email With Attachments via SMTP.