ID: 3754934c83ed4fffe37aac69d443db44b8db8215
14 lines
—
544B —
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(to_address, subject, body):
email_message = MIMEText(body)
email_message['From'] = settings['email']['from']
email_message['To'] = to_address
email_message['Subject'] = subject
# Open pipe to sendmail
child_process = Popen([ settings['email']['sendmail_path'], "-t" ], stdin=PIPE)
child_process.communicate(email_message.as_bytes())
|