无法使用 nodemailer 和 outlook 发送电子邮件
Can't send email with nodemailer and outlook
我尝试使用 nodemailer 和 outlook 发送电子邮件,但在多次尝试和访问多个论坛后,我什么也没发现。
我尝试了我见过的所有解决方案,但没有任何效果。你能帮帮我吗
这是我的代码:
{
const path = require('path');
var message=fs.readFileSync(path.join(__dirname+'../../../asset/templateMail/mail.html')).toString();
message=message.replace('${user}', user.confirmation_code.toString());
var nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport(
{
//service :"Outlook365",
//pool:true,
host: 'SMTP.office365.com',
port: '587',
secure:false,
auth: { user: "it-factory-flex@outlook.fr", pass: process.env.NODEMAILLERPASS },
//secureConnection: false,
//requireTLS:true,
//tls: { ciphers: 'SSLv3' }
}
);
var mailOptions = {
name:"FlexOffice",
from: "it-factory-flex@outlook.com",
to: user.email,
subject: "FlexOffice: Code d'inscription",
html: message
}
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
}
评论部分均为本人测试
我总是得到这个:
Error: Connection timeout
at SMTPConnection._formatError (/home/romain/bred/flex-server/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
at SMTPConnection._onError (/home/romain/bred/flex-server/node_modules/nodemailer/lib/smtp-connection/index.js:770:20)
at Timeout.<anonymous> (/home/romain/bred/flex-server/node_modules/nodemailer/lib/smtp-connection/index.js:235:22)
已解决,由于我的网络屏蔽了通量。
我尝试使用 nodemailer 和 outlook 发送电子邮件,但在多次尝试和访问多个论坛后,我什么也没发现。 我尝试了我见过的所有解决方案,但没有任何效果。你能帮帮我吗
这是我的代码:
{
const path = require('path');
var message=fs.readFileSync(path.join(__dirname+'../../../asset/templateMail/mail.html')).toString();
message=message.replace('${user}', user.confirmation_code.toString());
var nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport(
{
//service :"Outlook365",
//pool:true,
host: 'SMTP.office365.com',
port: '587',
secure:false,
auth: { user: "it-factory-flex@outlook.fr", pass: process.env.NODEMAILLERPASS },
//secureConnection: false,
//requireTLS:true,
//tls: { ciphers: 'SSLv3' }
}
);
var mailOptions = {
name:"FlexOffice",
from: "it-factory-flex@outlook.com",
to: user.email,
subject: "FlexOffice: Code d'inscription",
html: message
}
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
}
评论部分均为本人测试 我总是得到这个:
Error: Connection timeout
at SMTPConnection._formatError (/home/romain/bred/flex-server/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
at SMTPConnection._onError (/home/romain/bred/flex-server/node_modules/nodemailer/lib/smtp-connection/index.js:770:20)
at Timeout.<anonymous> (/home/romain/bred/flex-server/node_modules/nodemailer/lib/smtp-connection/index.js:235:22)
已解决,由于我的网络屏蔽了通量。