Created
April 1, 2025 10:23
-
-
Save heitara/4c6cd974d4cd2cec64bfc1c519317a74 to your computer and use it in GitHub Desktop.
Zoho setup with nodemailer using NodeJS
This file contains hidden or 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
import nodemailer from 'nodemailer'; | |
process.env.SMTP_HOST = "smtppro.zoho.eu"; | |
process.env.SMTP_PORT = "587"; | |
process.env.SMTP_USERNAME = "[email protected]"; | |
process.env.SMTP_SENDEREMAIL = "[email protected]"; | |
process.env.SMTP_PASSWORD = "password"; | |
const transporter = nodemailer.createTransport({ | |
host: process.env.SMTP_HOST, | |
port: process.env.SMTP_PORT, | |
secure: false, | |
auth: { | |
user: process.env.SMTP_USERNAME, | |
pass: process.env.SMTP_PASSWORD | |
} | |
}); | |
async function main() { | |
// send mail with defined transport object | |
console.log('Sending email...'); | |
const info = await transporter.sendMail({ | |
from: `"6th.tech team" <${process.env.SMTP_SENDEREMAIL}>`, // sender address | |
to: "[email protected]", // list of receivers | |
subject: "[Local] Test email from Zoho", // Subject line | |
text: "Hello from Zoho!", // plain text body | |
html: "<b>Hello world?</b>", // html body | |
}); | |
console.log("Message sent: %s", info.messageId); | |
} | |
main().catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment