Sending Email with Python 3
02 Jul 2017A common task in any popular programming language is the ability to send emails to your users, be it as a password reset or as a contact page submission on a blog just like this one.
The below snippet can be used to accomplish this, just change the variables depending on your use case. It assumes that you have a local SMTP server running on the machine you are running the script on (Postfix
for example), however you can also login to another service if you want to send via Gmail or Outlook etc.
You can also add additional properties to the MIME message for extra functionality:
Reply-To: Name <address>
to specify who the receiver should send their replies to- Change the
Content-type
totext/html
if you want to use HTML within your message body for styling
For more information take a look at the smptlib docs.