【发布时间】:2018-02-01 21:50:33
【问题描述】:
我正在使用 nodemailer 发送电子邮件,尤其是到 Outlook。
更新:
使用下面的代码我得到错误:消息失败错误
var nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: 'smtp.office365.com',
port: 587,
secureConnection: false, // secure:true for port 465, secure:false for port 587
auth: {
user: 'user@domain.com',
pass: 'password'
},
tls: { ciphers: 'SSLv3' }
});
// setup email data with unicode symbols
let mailOptions = {
from: '"Fred Foo ????" <foo@blurdybloop.com>', // sender address
to: 'myemail@companydomain.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ?', // plain text body
html: '<b>Hello world ?</b>' // html body
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
完整的错误跟踪:
错误:消息失败:550 5.7.60 SMTP;客户端无权作为此发件人发送 [SG2PR06MB1725.apcprd06.prod.outlook.com] 在 SMTPConnection._formatError (/var/www/html/Express/Local-MEAN-dev/node_modules/nodemailer/lib/smtp-connection/index.js:557:19) 在 SMTPConnection._actionSMTPStream (/var/www/html/Express/Local-MEAN-dev/node_modules/nodemailer/lib/smtp-connection/index.js:1385:34) 在 SMTPConnection._responseActions.push.str (/var/www/html/Express/Local-MEAN-dev/node_modules/nodemailer/lib/smtp-connection/index.js:907:22) 在 SMTPConnection._processResponse (/var/www/html/Express/Local-MEAN-dev/node_modules/nodemailer/lib/smtp-connection/index.js:706:20) 在 SMTPConnection._onData (/var/www/html/Express/Local-MEAN-dev/node_modules/nodemailer/lib/smtp-connection/index.js:509:14) 在 TLSSocket._socket.on.chunk (/var/www/html/Express/Local-MEAN-dev/node_modules/nodemailer/lib/smtp-connection/index.js:657:51) 在 emitOne (events.js:96:13) 在 TLSSocket.emit (events.js:191:7) 在 readableAddChunk (_stream_readable.js:176:18) 在 TLSSocket.Readable.push (_stream_readable.js:134:10) 在 TLSWrap.onread (net.js:563:20) 代码:'消息', 响应:'550 5.7.60 SMTP;客户端无权作为此发件人发送 [SG2PR06MB1725.apcprd06.prod.outlook.com]', 响应代码:550, 命令:“数据”}
【问题讨论】:
-
我想我是通过这个链接解决的:stackoverflow.com/questions/25357440/… 我的发件人地址和用户名不匹配...
标签: node.js email nodemailer