Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send HTML e-mail in App Engine / Python?

Tags:

Can you please give me a simple, and straightforward python example of sending an HTML e-mail using App Engine? Plaintext is straightforward, but I'm having difficulties with HTML tags.

like image 410
Silver Dragon Avatar asked May 18 '10 19:05

Silver Dragon


People also ask

How do I send an email from the App Engine?

php require_once 'google/appengine/api/mail/Message. php'; use google\appengine\api\mail\Message; $message_body = 'Hello. This is the body of the message. '; $mail_options = [ 'sender' => '[email protected]', 'to' => '[email protected]', 'subject' => 'Your account has been activated.

How do I send mail from a Python script?

Set up a secure connection using SMTP_SSL() and . starttls() Use Python's built-in smtplib library to send basic emails. Send emails with HTML content and attachments using the email package.

What email does Google App Engine use?

The mail API provides two ways to send an email message: the mail. send_mail() function and the EmailMessage class. This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment.


1 Answers

I haven't tested this, so please forgive any little bugs. It's based on an example from the Google documentation: http://code.google.com/appengine/docs/python/mail/sendingmail.html

from google.appengine.api import mail  message = mail.EmailMessage(sender="Example.com Support <[email protected]>",                             subject="Your account has been approved")  message.to = "Albert Johnson <[email protected]>"  message.body = """ Dear Albert:  Your example.com account has been approved.  You can now visit http://www.example.com/ and sign in using your Google Account to access new features.  Please let us know if you have any questions.  The example.com Team """  message.html = """ <html><head></head><body> Dear Albert:  Your example.com account has been approved.  You can now visit http://www.example.com/ and sign in using your Google Account to access new features.  Please let us know if you have any questions.  The example.com Team </body></html> """  message.send() 
like image 88
ʇsәɹoɈ Avatar answered Oct 05 '22 23:10

ʇsәɹoɈ