Introduction

Zoho Mail provides secure SMTP servers that allow you to send emails from external applications. Using Node.js and Nodemailer, you can easily integrate Zoho Mail into your projects for automated emails, notifications, or contact forms. This guide focuses on Zoho India accounts (.in) and covers SSL and TLS configurations.

Prerequisites

  • Node.js installed
  • A Zoho Mail account (@zohomail.in)
  • Nodemailer library (npm install nodemailer)
  • Optional: App-specific password if Two-Factor Authentication (2FA) is enabled

SMTP Configuration for Zoho India

For Personal/Free Accounts:

  • SMTP Host: smtp.zoho.in
  • SSL Port: 465 (secure: true)
  • TLS Port: 587 (secure: false)
  • Authentication: required

For Paid Domain Accounts:

  • SMTP Host: smtppro.zoho.in
  • Ports and security: same as above

Ensure your user email address matches your Zoho account exactly.

Step 1: Install Nodemailer

bash
npm install nodemailer

Step 2: Configure Transporter

js
const nodemailer = require('nodemailer'); const transporter = nodemailer.createTransport({ host: 'smtp.zoho.in', // Zoho India SMTP port: 465, // SSL port secure: true, // true for SSL auth: { user: 'your-email@zohomail.in', pass: 'your-app-password', // required if 2FA is enabled }, });

Step 3: Define Email Options

js
const mailOptions = { from: '"Raiyan Hasan" <your-email@zohomail.in>', to: 'receiver@gmail.com', subject: 'Test Email via Zoho SMTP', text: 'This is a test email sent from Node.js using Nodemailer and Zoho Mail.', };

Step 4: Send Email

js
transporter.sendMail(mailOptions, (err, info) => { if (err) console.error('Error sending email:', err); else console.log('Email sent successfully:', info.response); });

Common Issues & Fixes

  1. Authentication Failed (535):

    • Use app-specific password if 2FA is enabled
    • Ensure user matches your .in email address exactly
  2. Port/Security Mismatch:

    • SSL → port 465, secure: true
    • TLS → port 587, secure: false
  3. Relaying Disallowed:

    • Ensure the “from” email matches your authenticated Zoho account

Conclusion

Sending emails from Node.js via Zoho Mail is straightforward with Nodemailer. Always use .in for Zoho India accounts, configure SSL/TLS correctly, and generate app passwords if needed. This setup can be used for automated notifications, newsletters, or contact form submissions in your Node.js applications.