1 #!/usr/bin/env python 2 import cgi 3 import os 4 5 print "Content-Type: text/plain\n\n" 6 print "Hello, lunch patron ", TheForm["username"].value 7 print "Dont forget to add 50 cents for delivery. " 8 9 print "\n\nThe following information was sent:" 10 11 lunchForm = cgi.FieldStorage() 12 13 p = os.popen("%s -t" % SENDMAIL, "w") 14 p.write("To: lunch@drugs.melb.colloqui.com\n") 15 p.write("From: " + lunchForm["username"].value + " <" \ 16 + lunchForm["email"].value + ">\n") 17 p.write("Subject: loi loi\n") 18 p.write("\n") # blank line separating headers from body 19 p.write("SourceIP " + os.environ['REMOTE_ADDR' + "\n") 20 21 p.write(lunchForm['email'value + "\n") 22 p.write(lunchForm['date1'value + "\n") 23 p.write(lunchForm['username'value + " wants\n") 24 for i in ('1', '2', '3', '4',): 25 orderNo = 'order' + i 26 riceType = 'rice' + i 27 print(i + ". " + lunchForm[orderNo].value + " with " + 28 lunchForm[riceType].value + " rice.") 29 p.write(i + ". " + lunchForm[orderNo].value + " with " + 30 lunchForm[riceType].value + " rice.\n") 31 32 p.write("\nSpecial Instructions: " + lunchForm['text1'value + "\n") 33 34 smStatus = p.close() 35 if smStatus != 0: 36 print "Sendmail exit status=", smStatus 37 38 print "Finished!"