nodemailer 因 namecheap 私人电子邮件而失败
nodemailer failing with namecheap private email
我在该网站上搜索了有效的答案,但一无所获。
我正在尝试设置 nodemailer 并不断收到此错误:
{"code":"EENVELOPE","command":"API"}
这是设置代码。我试过使用和不使用 TLS
(port: 465
和 port: 587
以及 secure: true
和 secure: false
的组合)
nodejs 代码:
function(resetToken, user, done) {
let smtpConfig = nodemailer.createTransport({
host: 'mail.privateemail.com',
port: 587,
secure: false,
auth: {
user: 'email',
pass: 'pass'
}
});
let mailOptions = {
to: user.email,
from: 'email',
subject: 'Password Reset For app',
text: 'Reset this'
};
smtpConfig.sendMail(mailOptions, function(err, info) {
if(err) {
res.json({
'message': err,
'info': info
});
}
res.json({
'message': 'Click the link in the email we just sent to reset your password'
});
});
}
所以它对我来说很好用。这是我的设置
var transporter = `nodemailer.createTransport({
host: 'mail.privateemail.com',
port: 587,
secure: false,
auth: {
user: 'user',
pass: 'pass'
}
});
var mailOptions = {
from: 'contact@domain.com',
to: req.body.email,
subject: 'Hi there',
text: 'I work'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});`
它也适用于安全端口。(465)
我在该网站上搜索了有效的答案,但一无所获。
我正在尝试设置 nodemailer 并不断收到此错误:
{"code":"EENVELOPE","command":"API"}
这是设置代码。我试过使用和不使用 TLS
(port: 465
和 port: 587
以及 secure: true
和 secure: false
的组合)
nodejs 代码:
function(resetToken, user, done) {
let smtpConfig = nodemailer.createTransport({
host: 'mail.privateemail.com',
port: 587,
secure: false,
auth: {
user: 'email',
pass: 'pass'
}
});
let mailOptions = {
to: user.email,
from: 'email',
subject: 'Password Reset For app',
text: 'Reset this'
};
smtpConfig.sendMail(mailOptions, function(err, info) {
if(err) {
res.json({
'message': err,
'info': info
});
}
res.json({
'message': 'Click the link in the email we just sent to reset your password'
});
});
}
所以它对我来说很好用。这是我的设置
var transporter = `nodemailer.createTransport({
host: 'mail.privateemail.com',
port: 587,
secure: false,
auth: {
user: 'user',
pass: 'pass'
}
});
var mailOptions = {
from: 'contact@domain.com',
to: req.body.email,
subject: 'Hi there',
text: 'I work'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});`
它也适用于安全端口。(465)