Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a message-id for email in python?

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?

like image 799
TIMEX Avatar asked Oct 12 '13 21:10

TIMEX


People also ask

How to create an email message in Python?

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.

How do I make my email Secure in Python?

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.

How to send emails using simple mail transfer protocol in Python?

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.

Is it possible to automate sending emails with Python?

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


1 Answers

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

like image 195
Jean-François Roche Avatar answered Oct 13 '22 15:10

Jean-François Roche