473,382 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

help using smptd

I'm having trouble using the smptd module. The docs are woefully inadequate
and inspecting the source didn't help either. So far I've figured out how
to subclass smtpd.SMTPServer and override the process_message method to
handle smtp messages. I create an instance of my server and it listens on
the given interface. I can connect to the port it's on and send SMTP
commands but it doesn't respond. I've verified that it's actually bound
and I'm connecting to the right port.

The server object doesn't appear to have any methods like poll() or loop()
to continually handle connections, which is all I want it to do. There is
a listen method but it does something else. Does SMTPServer have an
equivalent to the serve_forever method of
BaseHTTPServer.BaseHTTPRequestHandler? If not how do I handle smtp
sessions? SMTPServer derives from asyncore/asynchat, but I didn't find
what I wanted there either.
import smtpd

class SMTPProxy (smtpd.SMTPServer):
def process_message (self, peer, mailfrom, rcpttos, data):
# my code here

proxy = SMTPProxy (listen_addr, relay_addr)
# now what?
--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
May 14 '06 #1
3 1477
Am Sonntag 14 Mai 2006 23:47 schrieb Dennis Lee Bieber:
On Sun, 14 May 2006 20:47:33 GMT, Edward Elliott <no****@127.0.0.1>

declaimed the following in comp.lang.python:
class SMTPProxy (smtpd.SMTPServer):


Don't you need to have an __init__() that invokes SMTPServer's
__init__()?


If you don't define an __init__() yourself (as it seems to be the case here),
MRO (and the rules associated with class methods) will take care that the
base class' __init__() gets called automatically.

--- Heiko.
May 14 '06 #2
Heiko Wundram wrote:
If you don't define an __init__() yourself (as it seems to be the case
here), MRO (and the rules associated with class methods) will take care
that the base class' __init__() gets called automatically.


Yes __init__ is being called. smtpd.PureProxy doesn't define its own init
either and it shows the same behavior as my class: binds to the port but
doesn't respond to connections.

--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
May 15 '06 #3
Edward Elliott wrote:
import smtpd

class SMTPProxy (smtpd.SMTPServer):
def process_message (self, peer, mailfrom, rcpttos, data):
# my code here

proxy = SMTPProxy (listen_addr, relay_addr)
# now what?


Update: I think I've solved it. SMTPServer registers with asyncore, so the
'now what' to handle connections is this:

asyncore.loop()

I tried that once before I posted without success, however I think I had
accidentally closed the socket already.

Now a follow-up question: does anyone know the purpose of the timeout
parameter to loop()? The asyncore docs say this:

"The timeout argument sets the timeout parameter for the appropriate
select() or poll() call, measured in seconds; the default is 30 seconds."

According to the select man page, timeout determines how long it blocks
before returning. But AFAICT, asyncore.loop() runs forever (as long as a
channel is open) no matter how long select blocks. What's the point of
passing a timeout for select when loop just calls it again every time it
returns?

--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
May 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mattigiat | last post by:
Sorry for being such a newbie in this respect, but here's my question: I have Visual Studio, with VB6 ent., with msdn help installed. Is there any way to downgrade to just using the VB5 help, on...
2
by: Patrick Lim | last post by:
Here is the problem: I have written a non-modal frame class in Java for displaying help text when a user is using an application. It works as desired in that if the user selects "help" again,...
10
by: Jacek Generowicz | last post by:
Where can I find concise, clear documentation describing what one has to do in order to enable Python's internal help to be able to provide descriptions of Python keywords ? I am in a situation...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
5
by: Steve Teeples | last post by:
Can someone point me to a document that clearly identifies the steps of creating a good help system for an application? I have a test tool that I'd like to add help to so that others will know how...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
6
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.