Python Google App Engine : Send Mail Error

I am writing a simple test application to send email using Python GAE. I am receiving below error in logs. I have tried empty body and other changes but nothing seems to be working. Is there any configuration changes that I need to make?

Traceback (most recent call last):

   File "/base/data/home/apps/s~xxxx/1.360190002979488583/email.py", line 5, in          from google.appengine.api import mail File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/mail.py", line 37, in          from email import MIMEBase               ImportError: cannot import name MIMEBase

Below is my app.yaml file

application: mailer
version: 1
runtime: python27
api_version: 1
threadsafe: no

handlers:
- url: /email
  script: email.py

libraries:
- name: webapp2
  version: "2.5.1"

Below is my email.py (essentially it is the same code as mentioned on https://developers.google.com/appengine/docs/python/mail/sendingmail . I have just changed from and to a valid email address)

from google.appengine.api import mail
import sys

message = mail.EmailMessage(sender="Example.com Support <valid-from-address@gmail.com>",
                            subject="Your account has been approved")

message.to = "Valid User <valid.user@gmail.com>"
message.body = """
Dear Albert:

Your example.com account has been approved.  

The example.com Team
"""

message.send()

Answers


Don't name your script email.py; that's what's preventing your import from the standard library's email module from working.


Need Your Help

How escape html in echo of javascript

javascript php

I can't escape my code JS in my echo :

PHP ImageMagick - readimage not working for certain pdfs

php pdf imagemagick imagick

I`m currently trying to run the readimage() function on PDFs.