Google App Engine将邮件副本发送到我的收件箱

0 投票
1 回答
563 浏览
提问于 2025-04-16 21:26

可能重复的问题:
使用GAE发送邮件时,如何停止发送给发件人自己的副本?

下面是一个用Python从Google App Engine发送邮件的代码。我创建了一个包含我想发送邮件的邮箱地址的列表(pythons),然后用循环逐个发送邮件,每次都重新设置消息的收件人并执行发送操作。

当在Google App Engine上运行下面的代码时,发件人(AUTH_USER1@gmail.com)会收到自己发送的邮件的副本,同时也会发送到我想要的邮箱地址。这可能是什么原因呢?

from google.appengine.api import mail
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import users

class MainPage(webapp.RequestHandler):
    def get(self):
    user = users.get_current_user()

    if user and user.nickname()=="AUTH_USER1":
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, ' + user.nickname())
    else:
        self.redirect(users.create_login_url(self.request.uri))



    message = mail.EmailMessage(sender="Auth User1 <AUTH_USER1@gmail.com>",
    subject="Testing Google App Engine")

    message.html = """

hi, how have you been
"""
    list = ['A@gmail.com','B@hotmail.com', 'C@yahoo.com']
    for i in range(0,len(list)):
        message.to = list[i]
        message.send()


application = webapp.WSGIApplication(
                                 [('/', MainPage)],
                                 debug=True)
def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

1 个回答

1

这是故意这样设计的。在App Engine中,你不能让用户发送邮件而不让用户自己收到一份副本。

撰写回答