I would like to add a unique RFC2822 compliant Message-ID
header to a message created using Python's built in email
library. How would I got about doing this? Is there a way within the library itself?
Python has EmailMessage class which can be used build email messages. This class ahs the required methods to customize different parts of the email message like - the TO and FROM tags, the Subject Line as well as the content of the email. In the below example we create an email message with all the necessary parts of an email.
Starting a Secure SMTP Connection When you send emails through Python, you should make sure that your SMTP connection is encrypted, so that your message and login credentials are not easily accessed by others. SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are two protocols that can be used to encrypt an SMTP connection.
Python comes with the built-in smtplib module for sending emails using the Simple Mail Transfer Protocol (SMTP). smtplib uses the RFC 821 protocol for SMTP.
Sending emails manually is a time-consuming and error-prone task, but it’s easy to automate with Python. Send emails with HTML content and attachments using the email package
This might help:
from email.utils import make_msgid
make_msgid()
This is described here:
https://docs.python.org/2/library/email.utils.html#email.utils.make_msgid
https://docs.python.org/3/library/email.utils.html#email.utils.make_msgid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With