Mailgun Domain not found: abc.com

匿名 (未验证) 提交于 2019-12-03 00:59:01

问题:

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

The nameserver in use is digital ocean and I also have a gmail account linked to the same (say using contact@abc.com).

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 contact@mg.abc.com.

However, trying to use the root domain (contact@abc.com) gives the following error:

AnymailRequestsAPIError: Sending a message to me@gmail.com from contact@abc.com ESP API response 404: { "message": "Domain not found: abc.com" } 

How do I resolve this issue?

回答1:

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

-- Original Answer You 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", "contact@abc.com",           ["to@example.com"],) 

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.

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",                              "contact@abc.com", ["to@example.com"]) 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.

For more information, see Anymail docs on esp_extra.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!