import smtplib smtp_host = 'your smtp host' server = smtplib.SMTP(smtp_host) ############################################################################### def send_email(_to, _from, _subject, _body): mime_fmt_body = ( "From: {email_from}\r\n" "To: {email_to}\r\n" "Subject: {subject_text}\r\n" "\r\n" "{body_text}\r\n" ).format(email_from=_from, email_to=_to,subject_text=_subject,body_text=_body) server.sendmail(_from, _to, mime_fmt_body) server.quit
A blog to help me remember what in the hell i've done and what not to do again. ever. Maybe you'll learn from my mistakes or epiphanies. Blog topics include SQL, T-SQL, Google, Windows, Visual Basic, Python, C#, etc.
Wednesday, May 22, 2013
Send email from Python
Save as Module "email.py". Import into your code and call with email.send_email(params)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment