123456789101112131415 |
- 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())
|