- #!/usr/local/bin/python
- from smtplib import SMTP
- import sys
- import sys
- import cgi
- import string
-
- #enable the next 2 lines for debugging purposes
- #import cgitb
- #cgitb.enable()
-
- print 'Content-type: text/html\n\n'
- form = cgi.FieldStorage()
- from_user=form.getvalue('FROM')[1]
- to_user=form.getvalue('TO')
- subject=form.getvalue('SUBJECT')
-
- msg=""
- for i in form.keys():
- if i=='FROM' :
- msg += str(i)+": " + form.getvalue(str(i))[1] +"\n"
- else:
- msg += str(i)+": " + form.getvalue(str(i)) +"\n"
-
- #mail sending.requires an SMTP service on the server
- mailserver="localhost"
- s=SMTP(mailserver)
- body = string.join((
- "From: %s" % from_user,
- "To: %s" % to_user,
- "Subject: %s" % subject,
- "",
- msg ), "\r\n")
- s.sendmail(from_user, [to_user], body)
- s.quit()
- s.close()
-
- #enable next 2 lines if your form define a redirect URL,after CGI processing
- #redirect_url="<meta HTTP-EQUIV=\"REFRESH\" content=\"0;url="+form.getvalue('GOTOURL')+"\">"
- #print redirect_url
-
#!/usr/local/bin/python
from smtplib import SMTP
import sys
import sys
import cgi
import string
#enable the next 2 lines for debugging purposes
#import cgitb
#cgitb.enable()
print 'Content-type: text/html\n\n'
form = cgi.FieldStorage()
from_user=form.getvalue('FROM')[1]
to_user=form.getvalue('TO')
subject=form.getvalue('SUBJECT')
msg=""
for i in form.keys():
if i=='FROM' :
msg += str(i)+": " + form.getvalue(str(i))[1] +"\n"
else:
msg += str(i)+": " + form.getvalue(str(i)) +"\n"
#mail sending.requires an SMTP service on the server
mailserver="localhost"
s=SMTP(mailserver)
body = string.join((
"From: %s" % from_user,
"To: %s" % to_user,
"Subject: %s" % subject,
"",
msg ), "\r\n")
s.sendmail(from_user, [to_user], body)
s.quit()
s.close()
#enable next 2 lines if your form define a redirect URL,after CGI processing
#redirect_url="<meta HTTP-EQUIV=\"REFRESH\" content=\"0;url="+form.getvalue('GOTOURL')+"\">"
#print redirect_url