简体   繁体   English

GAE send_mail无法正常工作

[英]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. 我希望用户提供的电子邮件成为发件人,“ receiver@example.com”接收电子邮件。

You can't change the sender address as you like. 您无法随意更改发件人地址。 See google's appengine docs for this: 请参阅Google的Appengine文档

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. 使用Google帐户登录的当前请求的用户地址。 You can determine the current user's email address with the Users API. 您可以使用Users API确定当前用户的电子邮件地址。 The user's account must be a Gmail account, or be on a domain managed by Google Apps. 该用户的帐户必须是Gmail帐户,或者位于由Google Apps管理的域上。 Any valid email receiving address for the app (such as xxx@APP-ID.appspotmail.com). 该应用程序的任何有效电子邮件接收地址(例如xxx@APP-ID.appspotmail.com)。 Any valid email receiving address of a domain account, such as support@example.com. 域帐户的任何有效电子邮件接收地址,例如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. 域帐户是Google域之外的帐户,其电子邮件地址不以@ gmail.com或@ APP-ID.appspotmail.com结尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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