I have been trying to send an email with Nodemailer from an email on Cpanel. When I was using Gmail, it was working fine but now I have switched to Cpanel (where a business mailbox is hosted), I don't get an error, just no email is sent. Here is my Nodemailer code:
var nodemailer = require("nodemailer")
var smtpTransport = require("nodemailer-smtp-transport")
var transporterDetails = smtpTransport({
host: 'my host',
port: 465,
secure: true,
auth: {
user: "example@emample.co.uk",
pass: "password123"
},
maxConnections: 5,
maxMessages: 10
})
module.exports = {
queryEmail: function(name, number, email, comments){
var transporter = nodemailer.createTransport(transporterDetails);
var mailOptions = {
from: 'example@example.co.uk',
to: 'example@example.com',
subject: "New Email",
html: "<p> An Email.</p>"
};
transporter.sendMail(mailOptions);
},
...
I have taken the host details from the Cpanel mailbox which looks like this:
I have tried a number of different configurations based on the Cpanel mailbox config but nothing seems to work (I have tried it without the SMTP block and just passing the object straight in the create transporterFunction). Without the SMTP block I get this error:
(node:14224) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 12): Error: getaddrinfo ENOTFOUND aventador.websitewelcome.com hostname.websitehello.com:465
Anything look wrong with the above code which might be stopping it?