Last active
October 17, 2022 12:32
-
-
Save amitbend/231cffcf86576432b55f61620db23b58 to your computer and use it in GitHub Desktop.
nodemailer with Zoho
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nodemailer = require('nodemailer'); | |
const transporter = nodemailer.createTransport({ | |
host: 'smtp.zoho.com', | |
port: 465, | |
secure: true, //ssl | |
auth: { | |
user: '[email protected]', | |
pass: 'yourpassword' | |
} | |
}); | |
function sendMail(err, env, botname) { | |
let mailOptions = { | |
from: '"My service name" <[email protected]>', // sender address (who sends) | |
to: '[email protected]', // list of receivers (who receives) | |
subject: `subject`, // Subject line | |
html: `<b>Time:</b> <p>email body</p>` // html body | |
}; | |
// send mail with defined transport object | |
return new Promise( | |
(resolve, reject) => { | |
transporter.sendMail(mailOptions, (error, info) => { | |
if (error) { | |
console.error(`couldn't send mail ${error}`); | |
reject(error) | |
} else { | |
console.log('Message sent: ' + info.response); | |
resolve(info.response) | |
} | |
}); | |
}) | |
} |
It worked for me, the solution of @amitbend. No further fixes. Just a detail for the host. I had to change the ".com" to ".eu" because my zoho host is located in Europe
Yes, Thank You @valeporti, I had stuck on this issue for a long time. Just had to change it from ".com" to ".in"
Thank you, @valeporti .
I'm Japanese, I resolved the problem. for 'smtp.zoho.com' change to 'smtp.zoho.jp'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anyone able to verify if that fix works?