javascript - 我可以使用 mailgun 中的沙箱域发送电子邮件,但不能使用经过验证的真实域
问题描述
我在托管我的网站的 netlify 上添加了所需的 dns 配置,当我转到我的域的 DNS 记录时,所有字段(TXT、MX、CNAME)上的所有刻度都是绿色的,所以我知道该域已经过验证。但是,我在发送消息时无法使用域并收到此错误:
Error: Forbidden
at IncomingMessage.<anonymous> (C:\Users\MSI\Desktop\mail\node_modules\mailgun-js\lib\request.js:327:17)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
statusCode: 401
}
这是我从 mailgun 文档中复制的代码,并将值更改为我的域和我的 api 密钥:
const mailgun = require('mailgun-js');
const DOMAIN = 'example.com';
//The domain is written in the exact same form (not https://example.com)
const api_key = '****************************************';
const mg = mailgun({ apiKey: api_key, domain: DOMAIN });
const data = {
from: 'Name <myemail@gmail.com>',
to: 'myemail@gmail.com',
subject: 'Hello',
text: 'Testing some Mailgun awesomness!',
};
mg.messages().send(data, (err, body) => {
if (err) throw err;
console.log(body);
});
我已经查看了有关此主题的所有 stackoverflow 问题,但似乎仍然没有找到问题所在(同样,上面的代码正在使用沙箱域)。帮助
解决方案
推荐阅读
- autohotkey - 执行 winkey 后任何可能的热键组合的任务
- php - jquery ajax php - 不止一次运行jquery代码的问题
- php - 如何使用 php json 创建正确的维度数组
- javascript - 从 ng-bootstrap Modal 删除后用新数据重新加载组件
- c# - NetCore 2.1 TestServer 返回 500 内部服务器错误
- image-processing - 如何使用 scipy.ndimage 找到最大的连接区域?
- java - 如何使用带有 Spring Boot 和 JavaFX 的 Maven 创建一个独立的 jar?
- java - 在 java 中使用 contains() 方法
- ios - 为什么会在没有调用 setActive: 的情况下激活自动布局约束?
- php - PHP TCPDF 在 ubuntu 14.04 上永久移动错误