我目前正在尝试从nodemailer发送邮件。
let transporter = nodemailer.createTransport({
host: 'smtp1.mailserver.com',
port: 25,
secure: false
});
app.post('/email', function (req, res) {
var body = req.body;
var mailAdresses = body.email;
var image = body.image;
var text = body.emailText;
// setup email data with unicode symbols
let mailOptions = {
from: 'myadress@mailserver.com', // sender address
to: mailAdresses, // list of receivers
subject: 'Image', // Subject line
html: text, // html body,
attachments: [
{
filename: "whiteboard.png",
content: image.split("base64,")[1],
encoding: 'base64'
}
]
};
//send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
这就是我正在使用的代码。我首先尝试端口587,然后我收到错误说
{ Error: connect ETIMEDOUT 15.241.140.74:587
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
code: 'ECONNECTION',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '15.241.140.74',
port: 587,
command: 'CONN' }
然后我尝试使用端口25和auth,然后我得到
code: 'EAUTH',
response: '503 5.5.1 Error: authentication not enabled',
responseCode: 503,
command: 'AUTH PLAIN' }
现在我在没有AUTH的情况下尝试了,我得到了:
code: 'EENVELOPE',
response: '450 4.7.1 <[127.0.0.1]>: Helo command rejected: Service temporarily unavailable',
responseCode: 450,
command: 'RCPT TO',
recipient: 'anotheraddress@address.com' } ] }
我没有遇到问题。
邮件服务器是一个使用outlook365的企业邮件服务器,我可以通过outlook使用邮箱,工作正常,我也找不到问题。
有人知道这个问题吗?