import smtplib from email.message import EmailMessage # the email message msg = EmailMessage() msg['Subject'] = 'CNP Assignment Email' msg['From'] = 'aadit@example.com' msg['To'] = 'shreyas@example.com' # used example.com just to not have a DNS error. msg.set_content('Hello World. This is a message that is to be captured for the CNP FISAC II.') #SMTP server running on localhost on port 25 with smtplib.SMTP('127.0.0.1', 25) as server: server.set_debuglevel(1) # debug output to see the SMTP conversation (for dev log) server.send_message(msg)