Reputation: 4767
I was using my google account to send emails in my application in development but now in production my client gave me cpanel email. I am using nodemailer module of nodejs to sending an emails. So i dont have enough knowledge of cpanel. i am able to login with my email credentials at mydomain.name/webmail.
I found code snippet to use cpanel email in nodemail like
var transporter = nodemailer.createTransport({
host: 'hostname',
port: 25,
auth: {
user: '----domain.com',
pass: '********'
}
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Order Recipt',
text: 'html'
};
So i didn't get what is port and host, where we have to configure it.
So help me how to use cpanel email in my application, what are the steps i have to follow.
Currently i am using nodemailer with my google account email like
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: configurationHolder.config.emailFrom,
pass: configurationHolder.config.emailPassword
}
});
var sendEmail = function (fromEmail, toEmail, subject, emailBody, html) {
transporter.sendMail({
from: fromEmail,
to: toEmail,
subject: subject,
text: emailBody,
html: html
});
}
Thanks
Upvotes: 2
Views: 11548
Reputation: 39
const transporter = nodemailer.createTransport({
host: "mail.*********.com",//this is the trick works for me, you have to insert 'mail' keyword before your domain name
port: 465,
secure: true,
auth: {
user: "donotreply@***********.com",
pass: "************",
},
});
Upvotes: 0
Reputation: 383
follow these steps : it worked for the mail id which I had created using cpanel
2 things to note here
a) in host where you had given the host name as "abc.com".. instead you can give the URL of the webmail too.. [remove the https].. as seen below in the image [do not include :2096 as seen in the image or any number/port info which you see in the url
b) if you still see an error, use "abc.com" and ensure you are using 465 and set the
secure : true
else if you are using other than 465; then set
secure : false
Upvotes: 3
Reputation: 2636
You can get this detail from the cpanel itself. see this link or this video
you only need hostname and port number detail, actually.
For username and password. You have to create one email Account in cpanel.
Upvotes: 2