node.js - nodemailer不发送邮件,给出250 ok
问题描述
我整个下午都在处理这个问题,欢迎所有想法。我目前正在运行以下示例代码来定位问题:
router.get('/', function(req, res, next) {
let transporter = nodemailer.createTransport({
host: "cpsrv14.misshosting.com",
port: 587,
secure: false,
auth: {
user: config.email.user,
pass: process.env.EMAIL_PASS
},
tls: {
rejectUnauthorized: false
}
});
// verify connection configuration
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log("Server is ready to take our messages");
}
});
transporter.sendMail({
from: '"Fred Foo " <foo@example.com>', // sender address
to: 'christopher.rosenvall@gmail.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
}).then(resp => {
console.log('Message sent: %s', JSON.stringify(resp));
res.status(200).json({
success: true
})
}).catch( err => {
console.log(err);
res.status(400)
});
});
应请求控制台给了我以下对我来说似乎没问题的信息:
Server is ready to take our messages
Message sent: {"accepted":["christopher.rosenvall@gmail.com"],"rejected":
[],"envelopeTime":84,"messageTime":403,"messageSize":603,"response":"250 OK id=1iFhm4-0004WG-
NM","envelope":{"from":"foo@example.com","to":["christopher.rosenvall@gmail.com"]},"messageId":"
<7f8f8aab-f900-1e8e-2cde-3da5ad2687ba@example.com>"}
GET / 200 762.254 ms - 16
我已经尝试过运行安全而不是运行安全,使用 tls 设置和不使用 - 只要我可以进行身份验证,似乎没有什么不同。
问题是电子邮件从未发送过,我尝试将其发送到一堆不同的电子邮件地址,但没有一个人收到电子邮件。
解决方案
仔细检查您是否在选项中给予。我遇到了这个问题。就我而言,我没有在选项字段中提供。但是从:fromemail@mail.com 获得后一切正常
推荐阅读
- python - 有没有办法使用 Talisman 将 content_security_policy 删除为 none?
- hadoop - 无法为 ZooKeeper 中的任何服务器 URI 打开客户端传输:GSS 启动失败——beeline 或 hive2 没有问题
- php - 使用 Ajax 在控件中返回视图
- python - 如何一次在pysftp中写入文件
- c# - AutoCompleteStringCollection - API - 问题的
- css - 增加图标的大小而不增加同一按钮内的文本大小>(文本+图标)>仅增加图标
- r - 如何在 R 中对 .csv 文件进行排序
- javascript - 使用 * 选择器为所有元素切换 CSS 转换按钮
- c++ - 如何在 While 循环中打印出矩阵格式的二维数组
- xamarin - 无法将 Custom.targets 文件添加到启用 Proguard 的 Xamarin Android 项目