how to send email in python?

chris at onca.catsden.net chris at onca.catsden.net
Tue Feb 6 08:24:35 CET 2001


On Tue, 6 Feb 2001, Sam Wun wrote:

> hi,
>
> does anyone knows? I am using python 1.6.

import os

f = os.popen ( "/usr/sbin/sendmail", "w" )

f.write ( """\
From: your address
To: recipient address
Subject: spam

spam spam wonderful spam spam spam
""" )


If you dont have sendmail on your system, or some other MTA, then you can
use smtplib to send it directly to an off-site MTA. I can get you some
simple code for that, but the above is the preferred way.


   ("`-/")_.-'"``-._        Ch'marr, a.k.a.
    . . `; -._    )-;-,_`)  Chris Cogdon <chmarr at furry.org.au>
   (v_,)'  _  )`-.\  ``-'
  _.- _..-_/ / ((.'       FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++
((,.-'   ((,/   fL               RLCT acl+++d++e+f+++h++i++++jp-sm++





More information about the Python-list mailing list