If I want to send mail not via SMTP, but rather via sendmail, is there a library for python that encapsulates this process?
Better yet, is there a good library that
Python 3.5+ version:
import subprocess
from email.message import EmailMessage
def sendEmail(from_addr, to_addrs, msg_subject, msg_body):
msg = EmailMessage()
msg.set_content(msg_body)
msg['From'] = from_addr
msg['To'] = to_addrs
msg['Subject'] = msg_subject
sendmail_location = "/usr/sbin/sendmail"
subprocess.run([sendmail_location, "-t", "-oi"], input=msg.as_bytes())