I\'ve been trying to get my application to mail some outputted text to an email. For simplification I have isolated the script :
import smtplib
import sys
import
For whatever reason, I had difficulty passing server and port to the constructor, but not the connect function. This ended up working for me:
s = smtplib.SMTP(timeout=30) #seconds
s.connect(EMAIL_HOST, EMAIL_PORT)
m = MIMEText('see subject')
m['subject'] = 'sweet subject'
m['from'] = EMAIL_FROM
m['to'] = to_list # comma-separated list of emails
s.sendmail(m['from'], m['to'].split(','), m.as_string())
s.quit()