import smtplib WEBMASTER = "webmaster@syndicat.com" # webmaster e-mail SMTP_SERVER = "localhost" # your SMTP server def email(req, name, email, comment): # make sure the user provided all the parameters if not (name and email and comment): return "A required parameter is missing, \ please go back and correct the error" # create the message text msg = """\ From: %s Subject: feedback To: %s I have the following comment: %s Thank You, %s """ % (email, WEBMASTER, comment, name) # send it out conn = smtplib.SMTP(SMTP_SERVER) conn.sendmail(email, [WEBMASTER], msg) conn.quit() # provide feedback to the user s = """\ Dear %s,
Thank You for your kind comments, we will get back to you shortly. """ % name return s