本文介绍了找不到Mailgun域:abc.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过我自己的网站设置电子邮件.假设域名为abc.com.

I am trying to setup emails with my own website. Let's say the domain name is abc.com.

正在使用的域名服务器是数字海洋,我也有一个与之关联的gmail帐户(例如使用[email protected]).

The nameserver in use is digital ocean and I also have a gmail account linked to the same (say using [email protected]).

在使用mailgun进行设置时,我使用了mg.abc.com(因为他们说这也可以让我使用根域发送电子邮件).验证步骤已完成,我可以使用[email protected]发送电子邮件.

While setting up things with mailgun, I used mg.abc.com (as they said it would also let me email using the root domain). The verification step is done and I can send email using [email protected].

但是,尝试使用根域([email protected])会出现以下错误:

However, trying to use the root domain ([email protected]) gives the following error:

AnymailRequestsAPIError: Sending a message to [email protected] from [email protected]
ESP API response 404:
{
"message": "Domain not found: abc.com"
}

如何解决此问题?

推荐答案

更新8/22/16:Anymail已更新,可以在settings.py中使用新的MAILGUN_SENDER_DOMAIN.请参阅.5+版本的文档.

Update 8/22/16:Anymail has been updated to take a new MAILGUN_SENDER_DOMAIN in settings.py. See version .5+ docs.

-原始答案您没有发布有关如何发送电子邮件的代码,但是您可能正在尝试使用简单的send_mail()函数进行发送:

--Original AnswerYou did not post your code for how you're sending your email, but you are probably trying to send using the simple send_mail() function:

from django.core.mail import send_mail

send_mail("Subject", "text body", "[email protected]",
          ["[email protected]"],)

使用此方法时,Anymail会将域从发件人"地址中拉出,并尝试与Mailgun一起使用.由于您的发件人地址(abc.com)不包含子域mg.,因此Mailgun感到困惑.

When you use this method, Anymail pulls the domain out of your From address and tries to use this with Mailgun. Since your From address (abc.com) doesn't include the subdomain mg., Mailgun is confused.

相反,您需要使用EmailMultiAlternatives对象发送电子邮件,并指定电子邮件发件人域,如下所示:

Instead, you need to send the email using the EmailMultiAlternatives object and specify the Email Sender Domain like so:

from django.core.mail import EmailMultiAlternatives

msg = EmailMultiAlternatives("Subject", "text body",
                             "[email protected]", ["[email protected]"])
msg.esp_extra = {"sender_domain": "mg.abc.com"}

msg.send()

不要忘记收件人"字段中的括号,因为即使您仅将其发送给一个收件人,它也必须是一个元组或列表.

Don't forget the brackets in your To field, as this needs to be a tuple or list even if you're only sending it to one recipient.

有关更多信息,请参见 esp_extra 上的Anymail文档.

For more information, see Anymail docs on esp_extra.

这篇关于找不到Mailgun域:abc.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:30