SMTP Integration Guide

What is SMTP

SMTP (Simple Mail Transfer Protocol) is the standard protocol for applications to submit emails to mail servers.
An application establishes a TCP connection to the SMTP server, enables TLS based on the access method, completes authentication, then specifies the sender, recipients and email content sequentially. The server returns an SMTP response code after accepting the email.

SMTP Session Sequence

The figure below illustrates the typical sequence of commands and responses between the client and server when an email is submitted to the SendCloud email platform over a secure connection, including the full AUTH LOGIN authentication process.


Integration Procedure

  1. Obtain the API User and API Key in the SendCloud email platform console.
  2. Connect to port 25 of smtp.sendcloud.net.
  3. Send EHLO, execute STARTTLS and complete the TLS handshake, then send EHLO again.
  4. Use the API User and API Key to complete authentication via AUTH LOGIN.
  5. Set the sender, recipients, subject and email body, then submit the email.
  6. Receiving the final 250 response means the email has been accepted by the SendCloud email platform.

Connection Methods & Authentication Parameters

ParameterValueDescription
SMTP Serversmtp.sendcloud.netSMTP entry point of the SendCloud email platform.
Port25SMTP connection port.
Encryption MethodSTARTTLSUpgrade to TLS after connection before authentication.
API UserAPI UserObtained from the console of the SendCloud email platform.
API KeyAPI KeyObtained from the console of the SendCloud email platform.
Authentication MethodAUTH LOGINCommon SMTP clients will automatically complete authentication interaction.

Python Sending Example

The following example uses Python standard libraries to establish a connection via port 25, perform STARTTLS, and send a plain-text email encoded in UTF-8.

import os
import smtplib
import ssl
from email.message import EmailMessage

SMTP_HOST = "smtp.sendcloud.net"
SMTP_PORT = 25
API_USER = os.environ["SENDCLOUD_API_USER"]
API_KEY = os.environ["SENDCLOUD_API_KEY"]

message = EmailMessage()
message["From"] = "[email protected]"
message["To"] = "[email protected]"
message["Subject"] = "Test Email from SendCloud Email Platform"
message.set_content("This is a test email sent via SMTP.")

ssl_context = ssl.create_default_context()

with smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=30) as client:
    client.ehlo()
    client.starttls(context=ssl_context)
    client.ehlo()
    client.login(API_USER, API_KEY)
    client.send_message(message)

print("Email submitted to SendCloud email platform")

Normal Response Codes

SMTP CodePhaseDescription
220Connection Establishment or STARTTLSSMTP service ready, or ready to initiate TLS handshake.
334AUTH LOGINServer requests API User or API Key.
235AUTH LOGINAuthentication succeeded.
250SMTP Command or Message SubmissionCommand executed successfully; the final 250 after DATA indicates the message has been accepted.
354DATAServer is ready to receive message headers and body.
221QUITSMTP session closed normally.