[英]Google Appengine sending emails: [Error] unauthorized sender
I'm trying to use google app engine's mail service on my site. 我正在尝试在我的网站上使用Google App Engine的邮件服务。 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="myapp@appspot.gserviceaccount.com",
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). 当我在本地尝试该站点时(使用
dev_appserver.py
),它没有显示错误,但没有发送电子邮件(注意:在本地尝试时,我必须添加--enable_sendmail
选项)。 The error only shows up when I publish the site. 该错误仅在我发布网站时显示。
Does anybody know what I'm doing wrong? 有人知道我在做什么错吗? Thanks in advance for your help!
在此先感谢您的帮助!
What is myapp@appspot.gserviceaccount.com? 什么是myapp@appspot.gserviceaccount.com? 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.
App Engine应用程序可以代表应用程序的管理员以及具有Google帐户的用户发送电子邮件。
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.
使用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结尾。
https://developers.google.com/appengine/docs/python/mail/sendingmail https://developers.google.com/appengine/docs/python/mail/sendingmail
First follow these steps 首先按照以下步骤
https://cloud.google.com/appengine/docs/python/mail/#who_can_send_mail https://cloud.google.com/appengine/docs/python/mail/#who_can_send_mail
Then you need to manually add the sender email in cloud console 然后,您需要在云控制台中手动添加发件人电子邮件
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. 您可能还必须将用于发送电子邮件的电子邮件地址添加到App Engine应用程序设置“电子邮件API”授权的发件人。
See https://cloud.google.com/appengine/docs/python/mail/#Python_Sending_mail 请参阅https://cloud.google.com/appengine/docs/python/mail/#Python_Sending_mail
在此处以管理员身份添加未经授权的电子邮件地址: https : //console.developers.google.com/project/_/permissions/projectpermissions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.