How to lunch webpage without using SMTP server?

Doug Holton insert at spam.here
Wed Jul 21 12:55:39 EDT 2004


Nancy wrote:
> Hi, Guys,
>   Is there any other way to use python or mod_python writing a web page?
> I mean, not use "form.py/email", no SMTP server.
>    <form action="form.py/email" method="POST"> ...
>    

So what you want is to be able to send email from a python script 
running on your Windows computer, but you don't have access to an SMTP 
server.
So you need to run your own SMTP server on your Windows computer.  If 
you want to do this for a real application, you should get a good SMTP 
server (there are some free ones like blat or xmail).

But here are steps to run a crude SMTP server implemented in Python.

Download the two python files from http://www.hare.demon.co.uk/pysmtp.html

Download the zip file for the PyDNS module from 
http://pydns.sourceforge.net/

You need to open a command window and install PyDNS.  Run "python 
setup.py install"

After you have installed PyDNS, then before you can run the SMTP server
you need to find out what DNS server your internet connection is using. 
  Go to control panel -> network.  Click on your network connection, hit 
the support tab and then click details to see what DNS servers you are 
using.  Copy one of them.

Then you can start the SMTP server in a command window.  Run "pyspy.py 
25 <dns server here>".

If it is running, then run this test script and see if you get the email:

import smtplib

SMTP_SERVER = "localhost"
FROMEMAIL = "wxling3 at hotmail.com"
TOEMAIL = "wxling3 at hotmail.com"

msg = """From: %s
Subject: test email
To: %s

This is a test message to %s
""" % (FROMEMAIL, TOEMAIL, TOEMAIL)

conn = smtplib.SMTP(SMTP_SERVER)
conn.sendmail(FROMEMAIL, [TOEMAIL], msg)
conn.quit()



More information about the Python-list mailing list