By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,292 Members | 1,699 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,292 IT Pros & Developers. It's quick & easy.

Sending e-mail with python 1.5.2

P: n/a
I am writing a CGI script on an account that only has Python 1.5.2. It's
principal purpose is to take some user input from a form, do some
manipulation and return some information to the user. However, I would
also like it to send some information to an e-mail account (behind the
scenes).

The e-mail could be quite simple, but I wouldn't rule out wanting to
send a pickled object or two.

Now if I was using a recent Python I would just use the email package,
but I don't think it's compatible with v1.5.2. I know I have access to
the sendmail binary, so something should be possible. Any pointers
gratefully received.

--
Andrew McLean
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I thought 1.5.2 had the smtp package. If not, how about just using
popen to send the mail through /bin/mail.
Jul 18 '05 #2

P: n/a
Thanks. smtplib was what I was looking for.

In article <7x************@ruckus.brouhaha.com>, Paul Rubin
<http@?.cx.invalid> writes
I thought 1.5.2 had the smtp package. If not, how about just using
popen to send the mail through /bin/mail.


--
Andrew McLean
Jul 18 '05 #3

P: n/a
Andrew McLean wrote:

I am writing a CGI script on an account that only has Python 1.5.2. It's
principal purpose is to take some user input from a form, do some
manipulation and return some information to the user. However, I would
also like it to send some information to an e-mail account (behind the
scenes).

The e-mail could be quite simple, but I wouldn't rule out wanting to
send a pickled object or two.

Now if I was using a recent Python I would just use the email package,
but I don't think it's compatible with v1.5.2. I know I have access to
the sendmail binary, so something should be possible. Any pointers
gratefully received.

--
Andrew McLean


This should help to get you going:

message = """\
Message-ID: <%(messageID)s>
Subject: %(subject)s
Date: %(date)s
From: %(fromstring)s <%(fromaddr)s>
Reply-To: %(fromaddr)s
X-Mailer: Python smtplib
%(to_cc_list)s

%(body)s
"""
try:
mail = smtplib.SMTP(LocalMailServer)
#mail.set_debuglevel(1)
mail.sendmail(fromaddr, email_recipients_tuple, message % locals())
mail.quit()
except:
print 'Could not send email!'

---

Richard.
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.