Sending e-mail

peter.jones.rpi at gmail.com peter.jones.rpi at gmail.com
Thu Aug 28 14:52:58 EDT 2008


I work at a training center and I would like to use Python to generate
a number of certificates and then e-mail them. The certificates are a
problem for another day - right now I just want to figure out how to
send an e-mail.

I confess I don't know much about the protocol(s) for e-mail. In PHP
using CodeIgniter, the same task was amazingly easy. I think this is a
bit harder because I'm not executing code on a remote machine that has
its own SMTP server. According to (http://www.devshed.com/c/a/Python/
Python-Email-Libraries-SMTP-and-Email-Parsing/), I need to use the
SMTP object found in the smtplib module to initiate a connection to a
server before I can send. I want to use Gmail, but on the following
input it stalls and then raises smtplib.SMTPServerDisconnected:

server = SMTP("smtp.gmail.com")

I also pinged smtp.gmail.com and tried it with the dotted quad IP as a
string. Am I on the right track? Is this a problem with gmail, or have
I gotten an assumption wrong?

Here's a thought: Could I use SMTPServer (http://docs.python.org/lib/
node620.html) to obviate the need to have anything to do with Gmail?
What would be the limitations on that? Could I successfully do this
and wrap the whole thing up in a black box? What modules would I need?

Thanks.



More information about the Python-list mailing list