A email.cgi script

dijk adijkstra at baandersconsultancy.nl
Mon Aug 16 03:23:40 EDT 2004


wonder <a at b.com> wrote in message news:<cfni2i$j0f$1 at news.hgc.com.hk>...
> Hi,
> 
> I would like to write a python script that can be used in my website for 
>   other people whoever browse my webside to send an email using my smtp 
> server. Is there any sample python script can do that?
> Here is my python script, but it does not display To and From editbox in 
> the webpage for user type in their addresses:
> 
> #!/usr/bin/python
> 
> import smtplib, cgi, string
> 
> form = cgi.FieldStorage()
> 
> # Change the lines below to specify the TO and
> # FROM addresses
> 
> toaddr = 'dest at abc.com'
> fromaddr = ''
> 
> # Special form fields used by the email.cgi
> # script
> 
> ack_url = form.getvalue('ack_url',None)
> ack_text = form.getvalue('ack_text','Your submission was successful')
> subject = form.getvalue('subject', '')
> 
> # form fields to skip
> to_skip = ['ack_url', 'ack_text', 'subject', 'to']
> 
> # create the email headers
> 
> msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddr, 
> subject)

I'm using almost the same syntax, but I'm not using '\r\n', only '\n'.

Hope this helps..



More information about the Python-list mailing list