【问题标题】:Email sending from address is gmail with django从地址发送的电子邮件是带有 django 的 gmail
【发布时间】:2014-04-09 14:18:15
【问题描述】:

小而烦人的问题,我已设置我的 django 应用程序以使用我公司的 gmail 帐户发送电子邮件。发送工作正常,但电子邮件中的发件人始终是 gmail 帐户。这是我的设置/代码 - 我已经更改了所有地址等,但要确保一切正常,除了来自电子邮件。

def send_discrepency_email(action, cart, atype):
    r = False
    user = cart.user
    subject = "%s - User Discrepency Response for order %s (%s)" % (action.upper(), cart.web_order_id, cart.syspro_order_id)
    message = "The user %s (%s) has opted to %s his/her order with the following discrepency type: %s." %(user.email, user.customer_id, action.upper(), atype)
    try:
        e = EmailMessage(subject, message, 'no-reply@rokky.com', ["ecommerce_requests@rokky.com", "pewet@s6688m.com"])
        e.send(fail_silently=False)
        r = True
    except Exception as e:
        print "Error sending discrepency email: %s" % e

    return r

注意:对于代码,我也尝试用 header kwarg 覆盖但无济于事。

DEFAULT_FROM_EMAIL = "ecommerce_requests@rokkyy.com"
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'no-actual-account@gmail.com'
EMAIL_HOST_PASSWORD = 'fakepword'
EMAIL_PORT = 587

这对 gmail 是否可行,我发誓我以前用过一次,效果很好。

简而言之,无论我进行什么更改,FROM 电子邮件始终是 no-actual-account@gmail.com

【问题讨论】:

  • 你的意思是说发件人是ecommerce_requests@rokkyy.com而不是no-reply
  • 不,抱歉,FROM 电子邮件始终是 no-actual-account@gmail.com 而不是 no-reply。我只是在发布之前添加了 SERVER_EMAIL 设置以查看它是否有帮助,我将从我的示例中删除。
  • 你有没有解决过这个问题,还是用 GMAIL 不可能?

标签: django email gmail


【解决方案1】:

这是 gmail 的安全设置。我使用自己编写的 Rails 应用程序遇到了这个问题。发件人地址必须是您使用“no-actual-account@gmail.com”登录的帐户或该帐户的别名。您始终可以只设置回复并获得与更改发件人地址类似的效果。或者您将不得不使用不同的 SMTP 服务器。

【讨论】:

  • 我可能应该关闭这个 - 无论如何我现在从事不同的工作:) 你基本上是正确的,我们只是切换到发送网格。问题解决了。
猜你喜欢
  • 2012-06-26
  • 2011-03-21
  • 1970-01-01
  • 2018-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-24
  • 2017-01-11
相关资源
最近更新 更多