Sending mail by Unauthorised sender in Google AppEngine

1.2k Views Asked by At

I've got a Google AppEngine Python application connected with my domain.
I want to be able to send emails from any email, like: mailname@mydomain.com

So I use sendmail() and set mailobject.sender = "[email protected]", but it does not work.
Also I made a receive function, but I don't want to receive mails here, so I just made

def receive(self, mail):
    pass

In Google Documentation https://cloud.google.com/appengine/docs/python/mail/receivingmail :

  • 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.

What should I add to the application in order to be able to send mails?

2

There are 2 best solutions below

0
On BEST ANSWER

From https://cloud.google.com/appengine/docs/python/mail/emailmessagefields

sender

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]).

This means that there is no documented way to send from *@example.org. I thought that there was a way if your @example.org was a google apps domain but I cannot find any docs on that.

5
On

Assuming mydomain.com is registered as a Google Domain Account, try adding [email protected] with the role 'Developer' in the Permissions section of the App Engine Admin Console: https://appengine.google.com/permissions?&app_id=s~yourapp (replace yourapp with your app's ID)

For more information see https://cloud.google.com/appengine/docs/python/mail/sendingmail