[Tutor] Sending email in Python...

Prahlad Vaidyanathan slime@vsnl.net
Wed, 17 Jul 2002 08:32:35 +0530


Hi,

On Mon, 15 Jul 2002 Danny Yoo spewed into the ether:
> On Sun, 14 Jul 2002, Belan, Martin ET3 (AGF-3) wrote:
> 
> >     I was wondering how one would go about sending an email using
> > python.  I am currently running python 2.2 under a Windows NT OS, which
> > utilizes a proxy server.  If anyone out there could aid my quest until I
> > am able to procure some decent documentation I would be much obliged.
> 
> Hi Belan,
> 
> You may find the 'smtplib' module appropriate --- SMTP is the protocol
> that computers use to send off email.

    Here is a module that is a wrapper around the MimeWriter and smtplib
modules (I think I posted the link sometime back as well), which I find
useful to send MIME messages :

    http://www.symonds.net/~prahladv/files/MailMsg.py

    Also, If you are interested, and you have a fairly recent python,
you could look up the 'email' module to construct your mail.

[-- snippity --]
> The docs also come with an example, so it should be enough to get you
> started.  However, I'm not quite sure how it works with a proxy, so
> perhaps someone else on the Tutor list can talk more about that.

    I'm just guessing, but shouldn't it suffice to set the $http_proxy
variable in the shell, or, do this :

    os.environ['http_proxy'] = 'http://www.proxy.com:3128'

HTH,

pv.
-- 
Prahlad Vaidyanathan  <http://www.symonds.net/~prahladv/>

The groundhog is like most other prophets; it delivers its message and then
disappears.