简体   繁体   中英

GAE send_mail not working

This script is not working,

class EmailPage(webapp2.RequestHandler):
    def post(self):
        try:
            mail.send_mail(
                self.request.get("email"), "receiver@example.com",
                self.request.get("subject"), self.request.get("body")
            )
        except: 
            self.response.out.write("Not working")

It responds with "Not working", but if I switch the sender and receiver it works fine. I want the email provided by the user to be the sender and "receiver@example.com" to receive the email.

You can't change the sender address as you like. See google's appengine docs for this:

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 xxx@APP-ID.appspotmail.com). Any valid email receiving address of a domain account, such as support@example.com. Domain accounts are accounts outside of the Google domain with email addresses that do not end in @gmail.com or @APP-ID.appspotmail.com.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM