smtpd module

S

Stefan Witzel

Hello,

the documentation of the smtpd module in the Python Library Reference
is very short, I think. Are there any examples available? Especially
I'm interested in the DebuggingServer.

Thanks in advance.

Stefan
 
G

Gabriel Genellina

En Wed, 06 Feb 2008 05:36:05 -0200, Stefan Witzel
the documentation of the smtpd module in the Python Library Reference
is very short, I think. Are there any examples available? Especially
I'm interested in the DebuggingServer.

Yes, the documentation is rather incomplete.
SMTPServer is an abstract class; it accepts local connections and handles
them, but doesn't know what to do with the received message. Subclasses
must override the process_message method to do something useful.

DebuggingServer is the simplest subclass; it just prints the received
message and nothing more, the message isn't delivered at all. Useful when
you want to test some program that sends messages but you don't want them
to be actually delivered.

PureProxy delivers the message to the upstream SMTP server (defined in the
constructor). By example:

localsmtpd = smtpd.PureProxy(('localhost',2500),('smtp.whatever.com',25))
asyncore.loop()

Then you (or your MUA, or any program, or a python script using smtplib)
can connect locally to port 2500 and send messages; they will be delivered
to smtp.whatever.com.

You can subclass PureProxy and pre-process the message before it is sent;
you could block some addresses, disallow attachments, add those annoying
disclaimers... MailmanProxy, by example, is a PureProxy subclass that
intercepts messages addressed to mailman and processes them directly.
 
S

Stefan Witzel

Stefan said:
Hello,

the documentation of the smtpd module in the Python Library Reference
is very short, I think. Are there any examples available? Especially
I'm interested in the DebuggingServer.

Thanks in advance.

Stefan

Sorry, I found the example - it's in the source file.

Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top