import os
import sys
from email.mime.text import MIMEText
import smtplib
import tempfile

email_content = tempfile.NamedTemporaryFile(mode='w+t')

print >>email_content, "This is my content"
print >>email_content, "Thank you for reading"

email_content.seek(0)

email_body = ""
for line in email_content :
    email_body = email_body + line

email_content.close()

msg = MIMEText(email_body)

msg['Subject'] = "This is my email message"
msg['From'] = "me@email.com"
msg['To'] = "you@email.com"

s = smtplib.SMTP("192.168.1.1",25)
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit()



import os
import sys
from email.mime.text import MIMEText
import smtplib
import tempfile

email_content = tempfile.NamedTemporaryFile(mode='w+t')

print >>email_content, "This is my content"
print >>email_content, "Thank you for reading"

email_content.seek(0)

email_body = ""
for line in email_content :
    email_body = email_body + line

email_content.close()

msg = MIMEText(email_body)

msg['Subject'] = "This is my email message"
msg['From'] = "sender@example.com"
msg['To'] = "recipient1@example.com,recipient2@example.com"

s = smtplib.SMTP("smtphost",25)
s.sendmail(msg['From'], msg['To'].split(","), msg.as_string())
s.quit()

Update email_example.py