B S
B S

Reputation: 11

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 <[email protected]>",
                            subject="Your account has been approved")

message.to = "Valid User <[email protected]>"
message.body = """
Dear Albert:

Your example.com account has been approved.  

The example.com Team
"""

message.send()

Upvotes: 1

Views: 1210

Answers (1)

Wooble
Wooble

Reputation: 89897

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

Upvotes: 6

Related Questions