Newbie CGI confusion...
Fred Mailhot
fred.mailhot at videotron.ca
Thu Feb 19 16:16:08 EST 2004
More information about the Python-list mailing list
Thu Feb 19 16:16:08 EST 2004
- Previous message (by thread): Newbie CGI confusion...
- Next message (by thread): PyImport_Import
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm trying to write a script that will mail some data from a web-based form
to me, using the "mail" command (under Linux). The following illustrates the
crux of what I'm doing:
#!/usr/bin/python
import os,time,cgi
#################################
# get the data from the form #
#################################
formdata = cgi.FieldStorage()
#################################
# open log file & write header #
#################################
logfile = open('<SOME FILE>','a')
logfile.write('\n*************************** ')
logfile.write(time.strftime("%a, %d %b %Y %H:%M:%S +0000",time.localtime()))
logfile.write(' ***************************\n')
####################
# send data to log #
####################
for name in formdata.keys():
logfile.write(formdata[name].value + '\n')
#########################################
# create shell command to send mail #
#########################################
usrmail = "%s" % formdata['email'].value
usrmesg = "Sender: %s\n\n%s" % (formdata['user'].value,
formdata['comments'].value)
ccaddr = "fred.mailhot at videotron.ca"
subject = "SMT Website User Feedback"
toaddr = "tilde at math.com"
cmdstring = 'mail -c %s -s "%s" -r %s %s' % (ccaddr, subject, usrmail,
toaddr)
os.popen(cmdstring,'w').write(usrmesg)
######## end code snippet #############
So. The script works and the relevant information is mailed, EXCEPT that the
body of the message is included as an attachment of unknown type. When I
execute the shell command from the command line, there's no problem.
Why is Python doing this ?? (or is it something else entirely that I'm not
understanding?)
Many thanks,
Fred.
- Previous message (by thread): Newbie CGI confusion...
- Next message (by thread): PyImport_Import
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list