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()
Don't name your script email.py
; that's what's preventing your import from the standard library's email
module from working.