Created
August 4, 2012 06:11
-
-
Save JonCooperWorks/3255049 to your computer and use it in GitHub Desktop.
Send email using Python on Google App Engine via Mail API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_email(form, to, name): | |
recipient = "%s <%s>" % (name, to) | |
subject = form.subject.data | |
sender = "%s <%s>" % (form.name.data, users.get_current_user().email()) | |
body = form.body.data | |
try: | |
mail.send_mail(sender=sender, to=recipient, subject=subject, body=body) | |
return True | |
except: | |
logging.error(traceback.extract_stack()) | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment