简体   繁体   English

未找到 Mailgun 域:example.com

[英]Mailgun domain not found: example.com

I am trying to setup emails with my own website.我正在尝试使用我自己的网站设置电子邮件。 Let's say the domain name is example.com .假设域名是example.com

The name server in use is digital ocean and I also have a gmail account linked to the same (say using contact@example.com ).使用的名称服务器是数字海洋,我也有一个链接到相同的 gmail 帐户(例如使用contact@example.com )。

While setting up things with mailgun, I used mg.example.com (as they said it would also let me email using the root domain).在使用 mailgun 进行设置时,我使用mg.example.com (因为他们说它也可以让我使用根域发送电子邮件)。 The verification step is done and I can send email using contact@mg.example.com .验证步骤已完成,我可以使用contact@mg.example.com发送电子邮件。

However, trying to use the root domain ( contact@example.com ) gives the following error:但是,尝试使用根域 ( contact@example.com ) 会出现以下错误:

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

How do I resolve this issue?我该如何解决这个问题?

I got the same error when I copy-pasted the curl example from Mailgun help page.当我从 Mailgun 帮助页面复制粘贴curl示例时,我遇到了同样的错误。

My domain was set to EU region, and I had to set the api domain to api.eu.mailgun.net instead of api.mailgun.net .我的域设置为欧盟地区,我必须将 api 域设置为api.eu.mailgun.net而不是api.mailgun.net

Boom!繁荣! Working!在职的! :) :)

I am using the EU region with Mailgun and have run into this problem myself.我正在使用带有 Mailgun 的欧盟地区,我自己也遇到了这个问题。 My implementation is a Node.js application with the mailgun-js NPM package .我的实现是一个带有mailgun-js NPM 包Node.js应用程序。

EU Region Implementation:欧盟地区实施:

const mailgun = require("mailgun-js");
const API_KEY = "MY_API_KEY";   // Add your API key here
const DOMAIN = "my-domain.example"; // Add your domain here
const mg = mailgun({
    apiKey: API_KEY,
    domain: DOMAIN,
    host: "api.eu.mailgun.net"  // -> Add this line for EU region domains
});
const data = {
    from: "Support <support@my-domain.example>",
    to: "recipient@example.com",
    subject: "Hello",
    text: "Testing some Mailgun awesomness!"
};
mg.messages().send(data, function(error, body) {
    if (error) {
        console.log(error);
    } else {
        console.log(body);
    }
});

Further options for the mailgun() constructor can be found here .可以在此处找到mailgun()构造函数的更多options

Thought I'd share a full answer for anybody that's still confused.以为我会为仍然感到困惑的任何人分享一个完整的答案。 Additionally, Mailgun Support was kind enough to supply the following table as a reference guide:此外,Mailgun Support 非常友好地提供了下表作为参考指南:

IF : IF

  • your domain is an EU domain AND您的域名是欧盟域名并且
  • you're using django-anymail as in Rob's answer above您正在使用django-anymail ,如上面 Rob 的回答

THEN the ANYMAIL setting (in your Django project settings) should specify the API_URL to be the EU one, example: THEN设置(在您的 Django 项目设置中)应将ANYMAIL API_URL为欧盟之一,例如:

ANYMAIL = {
    'MAILGUN_API_KEY': '<MAILGUN_API_KEY>',
    'MAILGUN_SENDER_DOMAIN': 'example.eu',
    'MAILGUN_API_URL': 'https://api.eu.mailgun.net/v3'  # this line saved me!
}

Before adding the MAILGUN_API_URL I was getting this error:在添加MAILGUN_API_URL之前,我收到了这个错误:

AnymailRequestsAPIError: Sending a message to xxx@example.com from noreply@example.eu <noreply@example.eu>
Mailgun API response 404 (NOT FOUND):
{
  "message": "Domain not found: mailgun.example.eu"
}

Update 8/22/16: Anymail has been updated to take a new MAILGUN_SENDER_DOMAIN in settings.py . 2016 年 8 月 22 日更新: Anymail 已更新为在settings.py中采用新的 MAILGUN_SENDER_DOMAIN。 See version .5+ docs.请参阅版本 .5+ 文档。

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

from django.core.mail import send_mail

send_mail("Subject", "text body", "contact@abc.example",
          ["to@example.com"],)

When you use this method, Anymail pulls the domain out of your From address and tries to use this with Mailgun.当您使用此方法时,Anymail 会从您的发件人地址中提取域并尝试将其与 Mailgun 一起使用。 Since your From address ( abc.example ) doesn't include the subdomain mg., Mailgun is confused.由于您的发件人地址 ( abc.example ) 不包含子域 mg.,因此 Mailgun 很困惑。

Instead, you need to send the email using the EmailMultiAlternatives object and specify the Email Sender Domain like so:相反,您需要使用EmailMultiAlternatives对象发送电子邮件并指定电子邮件发件人域,如下所示:

from django.core.mail import EmailMultiAlternatives

msg = EmailMultiAlternatives("Subject", "text body",
                             "contact@abc.example", ["to@example.com"])
msg.esp_extra = {"sender_domain": "mg.abc.example"}

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.不要忘记 To 字段中的括号,因为这需要是一个元组或列表,即使您只是将它发送给一个收件人。

For more information, see Anymail docs on esp_extra .有关更多信息,请参阅 esp_extra 上的Anymail文档。

Struggled for days with correct DNS settings and finally found as @wiktor said, i needed to add "eu" to api endpoint to make it work.用正确的 DNS 设置挣扎了好几天,最后发现正如@wiktor 所说,我需要将“eu”添加到 api 端点以使其工作。 Its actually also documented here: https://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions它实际上也记录在这里: https ://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions

Sorry for replying as an answer, dont have enough rep to add comment :(很抱歉作为答案回复,没有足够的代表来添加评论:(

I had the same problem: 404 error, domain not found.我遇到了同样的问题:404 错误,找不到域。

The cause The EU region selection for the domain on Mailgun原因Mailgun 上域的欧盟区域选择

The solution Change the region from EU back to the default of US.解决方案将区域从欧盟更改回默认的美国。

Since I had not used the domain at all up to this point, I simply deleted it, re-added it, then changed my TXT, MX and CNAME records (for example, mailgun.org instead of eu.mailgun.org) at the domain registrar (which was GoDaddy in my case).由于到目前为止我还没有使用过该域,所以我只是将其删除,重新添加,然后在域名注册商(在我的例子中是 GoDaddy)。

I found my fix with this change:我找到了解决此更改的方法:

ANYMAIL = {
   ...
   'MAILGUN_SENDER_DOMAIN': 'example.com', # Using the sending domain in Mailgun
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将域从 example.com 更改为 example.com/homepage/ - How to change the domain from example.com to example.com/homepage/ Django + gunicorn + nginx网站在使用example.com:8000时运行完美,但在使用example.com时却运行不完美 - Django+gunicorn+nginx site runs perfect when using example.com:8000 but not when using example.com Laravel&Mailgun:在生产中未找到枪口 - Laravel & Mailgun: Guzzle not found in production Dokku域名:添加 <app><domain> 返回找不到支持的vhost配置。 禁用vhost支持 - Dokku domains:add <app> <domain> returns unsupported vhost config found. disabling vhost support 链接现有域名后,DigitalOcean Droplet上的PHPmyAdmin出现404找不到错误 - 404 Not Found Error for PHPmyAdmin on DigitalOcean droplet following linking of existing domain name 如何在Node.js中使用Mailgun接收电子邮件? - How to receive emails with mailgun in Node.js? Django-Anymail在Digital Ocean上的docker中出现“Mailgun Magnificent API”错误 - “Mailgun Magnificent API” error with Django-Anymail in docker on Digital Ocean 在生产服务器(DigitalOcean)上的rails应用程序中使用哪个端口通过SMTP(mailgun)发送电子邮件? - What port to use sending email with SMTP (mailgun) in rails app on production server (DigitalOcean)? 使用参数将子域重定向到另一个域 - Redirect sub domain to another domain with parameters 域被重定向到同一液滴中的另一个域 - Domain is redirected to another domain in same droplet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM