我正在尝试使用以下代码使用 python 和 google appengine 发送电子邮件: main2.app
import webapp2
from google.appengine.api import mail from google.appengine.api import users
class InviteFriendHandler(webapp2.RequestHandler):
def post(self):
user = users.get_current_user()
if user is None:
login_url = users.create_login_url(self.request.path)
self.redirect(login_url)
return
to_addr = "madhurima.basu@gmail.com"
if not mail.is_email_valid(to_addr):
# Return an error message...
pass
message = mail.EmailMessage()
message.sender = user.email()
message.to = to_addr
message.body = """
I've invited you to Example.com!
To accept this invitation, click the following link,
or copy and paste the URL into your browser's address
bar:
%s
""" % generate_invite_link(to_addr)
message.send()
**app.yaml**
application: r-email
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /.*
script: main2.py
当我将此代码部署到谷歌引擎时,它运行时没有任何错误,但收件人没有收到任何电子邮件。同样在仪表板中,它显示 39% 的“收件人已通过电子邮件发送”..