"Mail receiver server"

M

manatlan

In an intranet/lan, i'd like to put a "python server script" (which run
forever) on a computer A...

On another computer B, I'd like to send smtp-email to the computer A ...
(send to "[email protected]", for example ...126.52.12.12 is the ip
address of "B")

in fact, i'd like to control "computer A" by sending smtp email from
"computer B".

What kind of server should i write on computer "B", a smtp server ? a
pop server ?
(i think i have to make a script which listen on a port, and execute
some handlers ... but i don't know how to start)

i know python very well, but i dont know anything about smtp/lan
if you have a recipe to build this kind of server, it could be good
but i'm pretty sure it can be easy to do ...
 
M

Mitja

in fact, i'd like to control "computer A" by sending smtp email from
"computer B".

What kind of server should i write on computer "B", a smtp server ? a
pop server ?

It would be easier if you used an existing mail server (which OS are you
running on comp B?), then use its redirecting features to pipe the
incoming mail to your python script. AFAIK most servers support that. Less
hassle, though probably a wee bit more intensive for the computer.
 
M

manatlan

Mitja a écrit :
It would be easier if you used an existing mail server (which OS are
you running on comp B?), then use its redirecting features to pipe the
incoming mail to your python script. AFAIK most servers support that.
Less hassle, though probably a wee bit more intensive for the computer.

the OS is a win32 (w2k), with IIS ... there is a "Virtual SMTP server"
in IIS ...

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 ...
 
K

Kartic

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
 
M

manatlan

Kartic a écrit :
manatlan said the following on 1/31/2005 5:46 PM:



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 ...
 

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,054
Latest member
TrimKetoBoost

Latest Threads

Top