[英]Why can't I send Email on Google app engine?
I CAN NOT send email on Google app engine. 我无法在Google应用引擎上发送电子邮件。
The sender_address is the owner of application. sender_address是应用程序的所有者。 I want to use "cron" to send email to someone every day. 我想用“cron”每天向某人发送电子邮件。
Here is my python code: 这是我的python代码:
class Send_Email(webapp2.RequestHandler):
def post(self):
self.abort(405, headers = [('Allow', 'GET')])
def get(self):
if 'X-AppEngine-Cron' not in self.request.headers:
self.error(403)
sender_address = "David <z25189347@gmail.com>"
user_email = "chaowc@mail.ncnu.edu.tw"
subject = "Work Complete!"
body = "Picture uploaded!"
mail.send_mail(sender_address, user_email, subject, body)
app = webapp2.WSGIApplication([(r'/', MainPage),
(r'/sendemail', Send_Email),
], debug=True)
Here is my cron.yaml code: 这是我的cron.yaml代码:
cron:
- description: Send Email
url: /sendemail
schedule: every day 00:00
timezone: Asia/Taipei
Here is my app.yaml code: 这是我的app.yaml代码:
handlers:
- url: /sendemail
script: main.app
- url: /.*
script: main.app
secure: always
When I run my application at localhost always show: 当我在localhost上运行我的应用程序总是显示:
Request to /sendemail succeeded!
But when I deploy to Google app engine , the logs always show wrong messages: 但是,当我部署到Google应用引擎时,日志始终显示错误消息:
InvalidSenderError: Unauthorized sender
I have no idea where I am doing wrong. 我不知道我在哪里做错了。 Someone help me please! 有人帮帮我! Thanks! 谢谢!
您需要在Developer Console> App Engine>设置>应用程序设置中将发件人电子邮件地址添加到授权发件人列表中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.