[Tutor] smtp project

Alan Plum alan.plum at uni-koeln.de
Mon Jan 18 01:24:08 CET 2010


On So, 2010-01-17 at 15:45 -0500, Kirk Z Bailey wrote:
> I am writing a script that will send an email message. This will 
> run in a windows XP box. The box does not have a smtp server, so 
> the script must crete not merely a smtp client to talk to a MTA, 
> it must BE one for the duration of sending the message- then shut 
> off, we don't need no bloody op0en relays here!

Twisted is the obvious choice for a server daemon, but it should be good
enough for what you do, too.

What you need isn't a "SMTP server", it's a "SMTP sender", which is more
like a client than a server in the usual model.

As you don't want it to run as a daemon, first consider how you want it
to behave if the server (SMTP receiver, the destination or a server that
is willing to relay the message) is not responding or responds with an
error.

A message queue (in terms of days not seconds) is out of the question
for a fire-and-forget service like the one you want, so you probably
want the transfer synchronously, i.e. somewhere between receiving the
user's input (or whatever triggers the script) and the output (or the
end of the lifetime of whatever script was triggered). If you're dealing
with real users, though, this can mean an unexpected pause of several
seconds, depending on how long the delivery takes (or how long it takes
to notice it's not going anywhere). This is bad if the user isn't
expecting it (zero progress can be interpreted as a freeze).

Anyway. Take a look at Twisted or other libraries for SMTP senders or
"clients". Actual SMTP servers are mostly concerned with accepting mail
via SMTP and doing something with them (if they are capable of relaying,
they can also act as SMTP senders, otherwise they probably just deliver
the mail locally or forward them to a local message queue for a separate
SMTP sender).


Hope that helped a bit,

Alan Plum



More information about the Tutor mailing list