← Back to Blog
Developer Guides14 May 2026 · NexusProMail Team

SMTP Configuration Guide for Email Sending

A practical guide to configuring SMTP for reliable email delivery — authentication, port selection, TLS, connection pooling, error handling and when to use SMTP vs REST API.

SMTP (Simple Mail Transfer Protocol) is the oldest and most widely supported email sending protocol. While modern integrations favour REST APIs for their observability and control, SMTP remains the right choice for legacy systems, CMSs and applications that cannot make HTTP requests.

Quick Answer

SMTP connects your application to a mail server that handles delivery. You authenticate with credentials, submit a message and the server routes it to the recipient. The key decisions are: which port to use, which encryption method, and how to handle errors.

SMTP vs REST API — which to use

Use the REST API for all new integrations. Use SMTP only when your application or framework cannot make HTTP requests — many CMSs, legacy frameworks and business applications only support SMTP configuration. For everything else, the REST API gives better error handling, webhook support and observability.

Connection settings

Host:       smtp.nexuspromail.com
Port:       587 (recommended) or 465
Encryption: STARTTLS on port 587 | TLS on port 465
Username:   your NexusProMail API key
Password:   your NexusProMail API key
Auth:       LOGIN or PLAIN

Port guidance:

  • Port 587 + STARTTLS — recommended. Starts unencrypted, upgrades to TLS. Works through most firewalls.
  • Port 465 + SSL/TLS — encrypted from connection start. Use if 587 is blocked.
  • Port 25 — do not use for sending. Blocked by most ISPs and cloud providers.

Configuration examples

Python (smtplib)

import smtplib, os
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

API_KEY = os.environ["NEXUSPROMAIL_API_KEY"]

def send_via_smtp(to, subject, html):
    msg = MIMEMultipart("alternative")
    msg["Subject"] = subject
    msg["From"] = "App "
    msg["To"] = to
    msg.attach(MIMEText(html, "html"))

    with smtplib.SMTP("smtp.nexuspromail.com", 587) as s:
        s.ehlo(); s.starttls(); s.ehlo()
        s.login(API_KEY, API_KEY)
        s.sendmail(msg["From"], [to], msg.as_string())

Node.js (Nodemailer)

const nodemailer = require("nodemailer")

const transporter = nodemailer.createTransport({
  host: "smtp.nexuspromail.com",
  port: 587,
  secure: false,
  auth: {
    user: process.env.NEXUSPROMAIL_API_KEY,
    pass: process.env.NEXUSPROMAIL_API_KEY,
  },
})

await transporter.sendMail({
  from: "App ",
  to, subject, html
})

PHP (PHPMailer)

$mail->isSMTP();
$mail->Host       = "smtp.nexuspromail.com";
$mail->SMTPAuth   = true;
$mail->Username   = $_ENV["NEXUSPROMAIL_API_KEY"];
$mail->Password   = $_ENV["NEXUSPROMAIL_API_KEY"];
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port       = 587;

Django (settings.py)

EMAIL_BACKEND    = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST       = "smtp.nexuspromail.com"
EMAIL_PORT       = 587
EMAIL_USE_TLS    = True
EMAIL_HOST_USER  = os.environ.get("NEXUSPROMAIL_API_KEY")
EMAIL_HOST_PASSWORD = os.environ.get("NEXUSPROMAIL_API_KEY")
DEFAULT_FROM_EMAIL  = "hello@mail.yourdomain.com"

TLS — never disable in production

Never set rejectUnauthorized: false (Node) or verify=False (Python) in production. These options disable certificate verification, removing the security TLS provides. Development only.

Connection pooling

Opening a new SMTP connection per email is slow. For batch sending:

  • Nodemailer: pool: true, maxConnections: 5, maxMessages: 100
  • Python: Keep the SMTP connection open across a batch using a context manager
  • High volume: Above 100 sends/minute, the REST API with async HTTP is more efficient than SMTP

SMTP limitations vs REST API

CapabilitySMTPREST API
Structured error responsesSMTP codes onlyFull JSON with error classification
Webhook delivery eventsComplex (VERP)Native — register once
Suppression feedbackBounce only422 with suppression reason
CompatibilityAny SMTP-capable systemRequires HTTP client

DNS prerequisites

SMTP sending requires the same DNS configuration as API sending: SPF, DKIM and DMARC records on your sending subdomain. See the subdomain strategy guide and the developer deliverability checklist for the full setup.

Related reading

Email deliverability guideGDPR complianceTransactional email API

Start sending with NexusProMail

Launch email campaigns and transactional emails from one platform.

Start FreeView Pricing

Free plan · No credit card required · GDPR-compliant · Built in Finland

SMTP Configuration Guide for Email Sending | NexusProMail