import smtplib for the actual sending function import the email modules we ll need open the plain text file whose name is in textfile for reading create a textplain message me the sender s email address you the recipient s email address send the message via our own smtp server import smtplib for the actual sending function import the email modules we ll need open the plain text file whose name is in textfile for reading create a text plain message me the sender s email address you the recipient s email address send the message via our own smtp server
import smtplib


from email.message import EmailMessage


with open(textfile) as fp:
    
    msg = EmailMessage()
    msg.set_content(fp.read())



msg['Subject'] = f'The contents of {textfile}'
msg['From'] = me
msg['To'] = you


s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()