ID: e40e46fddf166376d1035e89046ddde08b039c87
15 lines
—
575B —
View raw
| from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from freepost import settings
from subprocess import Popen, PIPE
def send (from_address, to_address, subject, body):
email_message = MIMEMultipart ()
email_message['From'] = from_address
email_message['To'] = to_address
email_message['Subject'] = subject
email_message.attach (MIMEText (body, 'plain'))
# Open pipe to sendmail
Popen ([ settings['sendmail']['path'] , "-t" ], stdin=PIPE) \
.communicate (email_message.as_bytes ())
|