Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Appengine sending emails: [Error] unauthorized sender

I'm trying to use google app engine's mail service on my site. It's showing some error whenever I visit the page that sends the email. The error says that I am using an unauthorized sender for the message. Here's the code that sends the email:

mail.send_mail(sender="[email protected]",
     to=input_dict["email"],
     subject="Mondays user activation",
     body=content)

When I try out the site locally (using dev_appserver.py) it doesn't show the error, but it doesn't send the email (Note: I have to add the --enable_sendmail option when I try it locally). The error only shows up when I publish the site.

Does anybody know what I'm doing wrong? Thanks in advance for your help!

like image 238
Harrison Avatar asked Jul 23 '12 21:07

Harrison


4 Answers

What is [email protected]? You might not be able to send mail from that address.

App Engine applications can send email messages on behalf of the app's administrators, and on behalf of users with Google Accounts.

The email address of the sender, the From address. The sender address must be one of the following types:

  • The address of a registered administrator for the application. You can add administrators to an application using the Administration Console.

  • The address of the user for the current request signed in with a Google Account. You can determine the current user's email address with the Users API. The user's account must be a Gmail account, or be on a domain managed by Google Apps.

  • Any valid email receiving address for the app (such as [email protected]).

  • Any valid email receiving address of a domain account, such as [email protected]. Domain accounts are accounts outside of the Google domain with email addresses that do not end in @gmail.com or @APP-ID.appspotmail.com.

https://developers.google.com/appengine/docs/python/mail/sendingmail

like image 69
user1258245 Avatar answered Nov 15 '22 18:11

user1258245


First follow these steps

https://cloud.google.com/appengine/docs/python/mail/#who_can_send_mail

Then you need to manually add the sender email in cloud console

How to add an authorized sender

like image 28
HimalayanCoder Avatar answered Nov 15 '22 20:11

HimalayanCoder


You may also have to add the email address you which to send the email from to the App Engine application settings Email API authorized senders.

See https://cloud.google.com/appengine/docs/python/mail/#Python_Sending_mail

like image 3
David Stack Avatar answered Nov 15 '22 20:11

David Stack


Add the unauthorized email address as an administrator here: https://console.developers.google.com/project/_/permissions/projectpermissions

like image 2
Oded Breiner Avatar answered Nov 15 '22 19:11

Oded Breiner