有人可以告诉您如何配置smtp服务器。使用的nodemailer和主机(smtp.gmail.com)。一切工作正常,直到将其发布到生产中为止,并且该服务器位于另一个国家/地区,并且Google需要通过具有超时(错误的选择)的令牌进行两因素身份验证,开始使用诸如sendgrid之类的其他身份,然后开始发送通常在远程服务器上,但他们没有去gmail即将到来。通过本地smtp服务器启动,就像服务器打印出来的那封信不见了。但是我没有收到一封信。有人可以帮忙解决此问题吗?
const nodemailer = require('nodemailer');
const smtpTransport = require('nodemailer-smtp-transport');
const transporter = nodemailer.createTransport(smtpTransport({
service: 'gmail',
host: 'smtp.gmail.com',
secure: false,
auth: {
user: 'info@gmail.com',
pass: 'ddd1904)',
},
tls: {
rejectUnauthorized: false
}
}));
const ownerMailTemplate = (entity, csv) => ({
from: 'no-reply@samesoft.network',
to: entity.email,
subject: 'Subscribing samesoft service ✔',
html: '<h4>Good day, Sergio!</h4>'
+ '<p>Congratulations! We have a new subscriber.</p>'
+ '<p>We have a combined 10 experience in the industry</p>',
attachments: [{
filename: 'emails.csv',
content: csv
}],
});
const message = await transporter.sendMail(ownerMailTemplate({ email: OWNER_EMAIL }, csv));
console.log("Message sent to owner: %s", message);