I'm currently trying to send a mail out of 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);
});
That is the code I'm using. I first tried port 587, then I got an error saying
{ 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' }
Then I tried with port 25 and with auth, then I get
code: 'EAUTH',
response: '503 5.5.1 Error: authentication not enabled',
responseCode: 503,
command: 'AUTH PLAIN' }
And now I tried it without AUTH and I get:
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' } ] }
And I don't get the problem.
The mail server is a corporate mail server that uses outlook365, I can use the mailbox through outlook and its working fine, and I don't find the problem.
Does anybody know the problem?