0
votes

I am trying to send an email from google app engine using the python 2.7 library but I keep getting Unauthorized sender in the logs. I have tried my gmail account I created the application with as the sender, I registered another gmail address as a developer and tried that but still get Unauthorized sender. I am not sure if it matters but I do have a domain name registered to this application.

Here is the code I am trying:

message = mail.EmailMessage()
        message.sender = "[email protected]"
        message.subject = "Inquiry"
        message.to = "[email protected]"
        message.body = "Please work"
        message.send()

I have looked at other articles to no avail.

Google Appengine sending emails: [Error] unauthorized sender

InvalidSenderError: Unauthorized sender (Google App Engine)

2

2 Answers

2
votes
from google.appengine.api import mail

mail.send_mail(sender="stackoverflow.com Hossam <[email protected]>",
              to="rsnyder <[email protected]>",
              subject="How to send an e-mail using google app engine",
              body="""
Dear rsnyder:

This example shows how to send an e-mail using google app engine

Please let me know if this is what you want.

Best regards,
""")

EDIT:

Note that sender must be an administrator of the application, so in case that you are not and administrator, follow these steps from the post google app engine: how to add adminstrator account

0
votes

I found the issue. It was the wrong version of the code. I switched to a version 2 and didn't realize I had to activate it.