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
If you don't want to run a separate server, and if you're only using Unix, you can use this technique, copied from http://www.yak.net/fqa/84.html, and originally from the Python FAQ:
On Unix, it's very simple, using sendmail. The location of the sendmail program varies between systems; sometimes it is /usr/lib/sendmail, sometime /usr/sbin/sendmail. The sendmail manual page will help you out. Here's some sample code:
SENDMAIL = "/usr/sbin/sendmail" # sendmail location
import os
p = os.popen("%s -t" % SENDMAIL, "w")
p.write("To: cary@ratatosk.org\n")
p.write("Subject: test\n")
p.write("\n") # blank line separating headers from body
p.write("Some text\n")
p.write("some more text\n")
sts = p.close()
if sts != 0:
print "Sendmail exit status", sts