我正在尝试在我的网站上使用 google app engine 的邮件服务。每当我访问发送电子邮件的页面时,它都会显示一些错误。该错误表明我正在使用未经授权的发件人来发送邮件。这是发送电子邮件的代码:
mail.send_mail(sender="myapp@appspot.gserviceaccount.com",
to=input_dict["email"],
subject="Mondays user activation",
body=content)
当我在本地试用网站(使用 dev_appserver.py
)时,它没有显示错误,但也没有发送电子邮件(注意:我必须添加 --enable_sendmail
选项,当我在本地尝试时)。该错误仅在我发布网站时出现。
有人知道我做错了什么吗?预先感谢您的帮助!
最佳答案
什么是 myapp@appspot.gserviceaccount.com?您可能无法从该地址发送邮件。
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 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.
https://developers.google.com/appengine/docs/python/mail/sendingmail
关于python - Google Appengine 发送电子邮件 : [Error] unauthorized sender,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11621019/