JK Docs
Backend

PHPMailer Configuration with Zoho SMTP

Last updated: 4/20/2026

Zoho SMTP Settings

SettingSSL (Port 465)TLS (Port 587)
SMTP Hostsmtp.zoho.comsmtp.zoho.com
Port465587
EncryptionSSLTLS/STARTTLS
Usernamefull emailfull email
Passwordemail passwordemail password

PHPMailer Code Example

<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; require 'lib/PHPMailer/PHPMailer.php'; require 'lib/PHPMailer/SMTP.php'; require 'lib/PHPMailer/Exception.php'; function sendTokenEmail(string $to, string $token): bool { $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.zoho.com'; $mail->SMTPAuth = true; $mail->Username = 'info@yourdomain.com'; $mail->Password = 'your-zoho-password'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; $mail->Port = 465; $mail->setFrom('info@yourdomain.com', 'Your App Name'); $mail->addAddress($to); $mail->isHTML(false); $mail->Subject = 'Your Login Token'; $mail->Body = "Your one-time login token: $token"; $mail->send(); return true; } catch (Exception $e) { error_log("Email error: {$mail->ErrorInfo}"); return false; } }

File Structure

your-project/
└── lib/
    └── PHPMailer/
        ├── PHPMailer.php
        ├── SMTP.php
        └── Exception.php

Or install via Composer:

composer require phpmailer/phpmailer

Important Notes

  • For reliable delivery to Gmail, ensure your domain has SPF and DKIM records configured (Cloudflare + Zoho setup)
  • Store SMTP credentials in config.php only (never commit to Git)
  • Zoho free plan supports up to ~500 emails/day from the SMTP relay
JK Docs
New Guide

Categories

DevOpsBackendFrontendDatabaseToolsSecurityDesignSystem Admin
Admin Panel