I've been at this problem all afternoon, all ideas are welcome. I'm currently running the following example code to locate the issue:
router.get('/', function(req, res, next) {
let transporter = nodemailer.createTransport({
host: "cpsrv14.misshosting.com",
port: 587,
secure: false,
auth: {
user: config.email.user,
pass: process.env.EMAIL_PASS
},
tls: {
rejectUnauthorized: false
}
});
// verify connection configuration
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log("Server is ready to take our messages");
}
});
transporter.sendMail({
from: '"Fred Foo " <foo@example.com>', // sender address
to: 'christopher.rosenvall@gmail.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
}).then(resp => {
console.log('Message sent: %s', JSON.stringify(resp));
res.status(200).json({
success: true
})
}).catch( err => {
console.log(err);
res.status(400)
});
});
On request console gives me the following which seems ok to me:
Server is ready to take our messages
Message sent: {"accepted":["christopher.rosenvall@gmail.com"],"rejected":
[],"envelopeTime":84,"messageTime":403,"messageSize":603,"response":"250 OK id=1iFhm4-0004WG-
NM","envelope":{"from":"foo@example.com","to":["christopher.rosenvall@gmail.com"]},"messageId":"
<7f8f8aab-f900-1e8e-2cde-3da5ad2687ba@example.com>"}
GET / 200 762.254 ms - 16
I've tried messing around with running secure and not, with the tls setting and without - doesn't seem to make a difference as long as I can authenticate.
Problem is that the email is never sent, ive tried sending it to a bunch of different email addresses and not a single one has recieved the email.