代码之家  ›  专栏  ›  技术社区  ›  chriscauley

如何使用AppEngine从非Gmail帐户发送电子邮件?

  •  4
  • chriscauley  · 技术社区  · 15 年前

    I have successfully sent an email using the Google App Engine. However the only email address I can get to work is the gmail address I have listed as the admin of the site. I'm running the app on my own domain (bought and maintained using Google Apps). I would like to send the email from my own domain. Here's the code (or something similar to it):

    from google.appengine.api import mail
    
    sender = "myaddress@google.com"
    sender_i_want = "myaddress@mygoogleapp.com"
    
    mail.send_mail(sender=sender,
        to="Albert Johnson <Albert.Johnson@example.com>",
        subject="Your account has been approved",
        body=some_string_variable)
    

    And the error I get when I try to send it from my own domain is "InvalidSenderError: Unauthorized sender". I own the domain, I do in fact authorize using my domain to send the mail, I just need to know how to convince the App Engine that this is true.

    1 回复  |  直到 15 年前
        1
  •  7
  •   Will McCutchen    15 年前

    这是对 App Engine's mail API :

    The sender address can be either the email address of a registered administrator for the application, or the email address of the current signed-in user (the user making the request that is sending the message).

    如果你在该域上运行了Google应用程序,你应该拥有(或者能够创建)一个@that domain.com电子邮件地址,你可以注册为相关应用程序引擎应用程序的管理员,然后你可以从该地址发送电子邮件。