I came across this issue when trying to send a basic test email in my expressJS app. After some research it became apparent that the issue was being caused by Gmail and not nodemailer itself, and that changing to a different service would fix the problem. However, after changing to hotmail I am still getting the same error? Can anybody provide some insight?
emailService.js
:
const nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
var transporter = nodemailer.createTransport({
service: 'hotmail',
auth: {
user: '****@outlook.com',
pass: '****'
}
});
// setup email data with unicode symbols
var mailOptions = {
from: '****@outlook.com', // sender address
to: '****@hotmail.co.uk', // list of receivers
subject: 'Test Email', // Subject line
text: 'Hello world ?' // plain text body
};
module.exports = {
sendTestEmail: function() {
transporter.sendMail(mailOptions, function(error, info) {
if(error){
console.log('error sending email: ' + error);
} else {
console.log('email sent' + info.response);
}
});
}
};
Then I am simply calling this function within the GET
function of one of my pages like so:
router.get('/', function (req, res) {
//Do some stuff
emailService.sendTestEmail();
//Do more stuff
});
Error: error sending email: Error: connect ETIMEDOUT 65.55.176.126:587
Many thanks!
via C Grant
No comments:
Post a Comment