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 accou
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.