How to get email id from smtplib

I want users to reply to my mail and display it as a stream in my application. For this purpose, I am using help-id currently in the email header. When I sent mail, I can see how the message identifier is displayed on the screen, how I can get this message identifier. The message id created by me is overridden. my code is as follows.

import smtplib from email.mime.text import MIMEText subject = 'Hello!' message = 'hiii!!!' email = ' someone@somewhere.com ' send_from = ' me@example.com ' msg = MIMEText(message, 'html', 'utf-8') msg['Subject'] = subject msg['From'] = send_from msg['To'] = email msg['Message-ID'] = '01234567890123456789abcdefghijklmnopqrstuvwxyz' send_to = [email] smtp_server = 'email-smtp.us-east-1.amazonaws.com' smtp_port = 587 user_name = 'abcd' password = 'abcd' try: server = smtplib.SMTP(smtp_server, smtp_port) server.set_debuglevel(True) server.starttls() server.ehlo() server.login(user_name,password) server.sendmail(send_from, send_to, msg.as_string()) except Exception, e: print e 
+6
source share
1 answer

Use email.utils.make_msgid to create a Message-ID header that is compliant with RFC 2822:

 msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] 
+1
source

All Articles