<reponame>yasser296/Python-Projects<filename>Python_Network_Automation_II/chapter16_codes/sendmail/sendmail_test01.py<gh_stars>0
from email.mime.text import MIMEText
from subprocess import Popen, PIPE

msg = MIMEText("Python & sendmail email test 01.")
msg["From"] = "<EMAIL>" # Update to your test email address
msg["To"] = "<EMAIL>" # Update to your test email address
msg["Subject"] = "Python & sendmail email test 01"
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE, universal_newlines=True)
p.communicate(msg.as_string())
print("Email sent!")
