"Mail receiver server"

manatlan manatlan_no_s_p_a_m at free.fr
Tue Feb 1 02:48:31 EST 2005


Kartic a écrit :
> manatlan said the following on 1/31/2005 5:46 PM:
> 
>>
>> I like the idea, but how to connect the virtual smtp and a python 
>> script ?
>>
>> but ... There should be a way to be python only ... because i don't 
>> want to be very complex, i just want to get the subject of the email, 
>> to run some commands (and perhaps get a attachment file) ... but 
>> that's all
>> i am pretty sure that a recipe exists ... that a man has already done 
>> that !
>> But i don't know what to query on google ...
> 
> 
> Hi,
> 
> What you are trying to do is what is called a mail filter. So google for 
> python mail filter and see what you get.
> 
> With this setup, lets say Computer B sends an email to user controluser 
> on Computer  A , the email is actually passed off to a script (in your 
> case python script) to process the incoming email, instead of actually 
> delivering the email to the user's inbox on "A".
> 
> I don't have the faintest the idea how you would do this on IIS's 
> virtual SMTP server; there is probably a setup user panel. In any case, 
> on UNIXish systems, there are a few ways of doing it of which one way is 
> to setup a user in a file called /etc/aliases and put an entry like this:
> 
> controluser: | /usr/local/bin/mailprocessor.py
> 
> which tells the SMTP server to pass off the email to script after the | 
> (pipe) when controluser gets an email.
> 
> So, see if the SMTP control panel provides you with some such feature. 
> If IIS does not, my suggestion to you will be to install Cygwin from 
> cygwin.com and use the Exim Mail transfer agent available with Cygwin 
> (You will have to choose that when installing Cygwin, it is not 
> automatically installed) or please google for Windows SMTP Server and 
> see if something piques your interest.
> 
> Now, coming to the Python related part. Your SMTP server will invoke 
> your script by sending the incoming email data on your script's sysin.
> 
> So, from python you will do...
> 
> #!/usr/local/bin/python
> import sys, email, os
> 
> em = email.message_from_file(sys.stdin) # Read message from Std Input
> subject = em.get('Subject')             # Get the subject from em object
> if subject.startswith('reboot'):
>    os.system('shutdown -r') # reboot the Server
> 
> For more information, please read the email module in the Python Module 
> Docs.
> 
> Hope that will help you get started!
> 
> Thanks,
> --Kartic

thanx a lot for yours informations ...
it was very interesting ...

in fact, i've already built a "smtp filter" with the virtual smtp server 
of iis ... (3 years ago)
But with techno of microsoft ... with event sink and vbs ...
and i think there is no way to do it with python ...
it could be possible to do it again with dot.net ...

but i've found what i wanted here :
http://www-106.ibm.com/developerworks/webservices/library/ws-pyth12.html

it seems it could be possible to build its own smtpd with python ... and 
interact in a simple way ...

i will choose this solution ... i'm fed up with microsoft way
and could be reused on my linux box too ;-)

i will have a look ...



More information about the Python-list mailing list