I am trying to use SMTP connection with nodemailer with office365 mail.
When I try to send mail, it throws up this error -
Error: connect ETIMEDOUT xx.xxx.xxx.xxx:587 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14) errno: 'ETIMEDOUT', code: 'ECONNECTION', syscall: 'connect', address: 'xx.xxx.xxx.xxx', port: 587
It is not a proxy issue, since I tried outside of the network and it throws up the same error as well.
`
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
host: 'smtp.office365.com',
secure: false,
auth: {
user: "[email protected]",
pass: "xxxxx"
},
tls: {
ciphers: 'SSLv3'
}
});
var message = {
from: 'Sender Name <[email protected]>',
to: '"Receiver Name" <[email protected]>',
subject: 'Nodemailer',
text: 'Hello to myself!'
};
transporter.sendMail(message, function(error, response) {
if (error) {
console.log('Error occured');
res.end("<html><body><h1>error</h1></body></html>");
console.log(error);
return;
} else {
console.log(response);
res.end("<html><body><h1>success</h1></body></html>");
console.log('Message sent successfully!');
}
});
`
I tried with other services as well like Gmail, it also gives the same error inside and outside the network.