SMTP API

Our SMTP API allows you to send email transmissions directly from your own mail server (or client). It acts as an intermediary, receiving your SMTP commands, constructing a mail object, and then processing it for transmission creation.
 

Configuration

To send emails via our SMTP, configure the following in your email client or app:

SMTP server name: smtp-campaigns.zoho.com

SMTP port: 587

SMTP encryption: STARTTLS

Authentication: Password/Login

Username: apikey

Password: The API key generated by you, from our application's API Keys page.

Other ports:

25: Plain and unencrypted
465: SSL

The recommended port is 587 with STARTTLS encryption

Code Samples

To help you get started quickly, we provide ready-to-use code samples in multiple programming languages. These examples demonstrate how to connect to our SMTP server, authenticate, and send messages using common libraries.

You can find the full set of examples in our GitHub repository

(Java, Python, Node.js, PHP, and Go).

SMTP with OpenSSL

You can use the openssl s_client tool to test your SMTP connection, encryption, and authentication.

1. Establish a Secure Connection:

openssl s_client -connect smtp-campaigns.zoho.com:587 -starttls smtp -ign_eof -crlf

This command connects to the Zoho Campaigns server on port 587 (standard for secure SMTP) and initiates a TLS handshake using the STARTTLS extension. The -ign_eof option ensures the command doesn't terminate prematurely, and -crlf specifies using CRLF (carriage return, line feed) as the line terminator.

2. Identify Yourself:

EHLO zylker.com


Send the EHLO command followed by your domain name (zylker.com in this example). This introduces your client to the server.
 

3. Authenticate with API Key:

Use the AUTH LOGIN command to send the API key (refer to Authentication section of the API documentation here).
 

AUTH LOGIN

334 Username

YXBpa2V5 // base64 encoded value for the string "apikey"

334 Password

MTAwMC4qKioqKioqKioqKioqLioqKioqKio= // base64 encoded password

235 Continue with the mail


4. Specify the Sender:

Use the MAIL FROM command to specify the email address of the sender. Enclose the address in angle brackets < >.

MAIL FROM:<aaron@zylker.com>

250 2.1.0 Sender <aaron@zylker.com> OK

 

5. Add Recipients:

Use the RCPT TO command for each recipient address. You can add up to 10,000 recipients per email. Enclose each address in angle brackets.

RCPT TO:<aaron.test@gmail.com>

250 2.1.5 Recipient <aaron.test@gmail.com> OK

RCPT TO:<ea.test@zylker.com>

250 2.1.5 Recipient <ea.test@zylker.com> OK

 

6. Compose the Email (DATA):

  • Use the DATA command to indicate the start of the email content.
  • Provide the email subject on a separate line.
  • Add the email body content.
  • Include any optional email metadata prefixed with X-ZCEA-SMTP-DATA: (refer to API documentation for supported metadata).
  • End the email content with a single dot (.) on a new line to signal the end of the message.

 

DATA

354 Ok Send data ending with <CRLF>.<CRLF>

Subject: My first mail using Zoho Campaigns Email API SMTP

X-ZCEA-SMTP-DATA:{"campaign_name":"Summer is here","recipient_data":{"aaron.test@gmail.com":{"name":"Aaron Fletcher","additional_data":{"phone":"+91231241444","country":"CA"},"merge_data":{"first_name":"Aaron"}},"ea.test@zylker.com":{"name":"EA Test","additional_data":{"phone":"+9198762313210","country":"CA"},"merge_data":{"first_name":"EA"}}},"from":{"address":"aaron@zylker.com","name":"Aron Fletcher"}}

 

Summer Hot Savings, You DonWant to Miss.

7. Success:

Upon successful completion of these steps, the server will send a response indicating the email has been accepted or rejected. Refer to 'Error Codes' documentation for information on response codes.