postkit
Guides

SMTP Relay

Send emails via SMTP instead of the REST API

If your application sends email via SMTP (mail libraries, legacy systems, CMS platforms), you can use Postkit as an SMTP relay. All emails sent via SMTP get the same DKIM signing, tracking, and webhook events as REST API sends.

Prerequisites: A verified domain and an API key. See Domain Setup.

SMTP connection settings

Configure your application with these SMTP settings:

SettingValue
Hostmail.postkit.eu
Port587 (STARTTLS) or 465 (implicit TLS)
UsernameYour API key (e.g., pk_live_abc123...)
PasswordYour API key (same as username)
EncryptionTLS required

Use your full API key as both the username and password. Sandbox keys (pk_test_...) work for testing without delivering real emails.

Configure your application

Node.js with Nodemailer

const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
  host: 'mail.postkit.eu',
  port: 587,
  secure: false, // STARTTLS
  auth: {
    user: 'pk_live_abc123...',
    pass: 'pk_live_abc123...',
  },
});

await transporter.sendMail({
  from: 'you@yourdomain.com',
  to: 'user@example.com',
  subject: 'Hello from Postkit SMTP',
  html: '<h1>It works!</h1><p>Sent via SMTP relay.</p>',
});

Python with smtplib

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

msg = MIMEMultipart('alternative')
msg['Subject'] = 'Hello from Postkit SMTP'
msg['From'] = 'you@yourdomain.com'
msg['To'] = 'user@example.com'

text = MIMEText('Sent via SMTP relay.', 'plain')
html = MIMEText('<h1>It works!</h1><p>Sent via SMTP relay.</p>', 'html')
msg.attach(text)
msg.attach(html)

with smtplib.SMTP('mail.postkit.eu', 587) as server:
    server.starttls()
    server.login('pk_live_abc123...', 'pk_live_abc123...')
    server.send_message(msg)

PHP with PHPMailer

use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host       = 'mail.postkit.eu';
$mail->SMTPAuth   = true;
$mail->Username   = 'pk_live_abc123...';
$mail->Password   = 'pk_live_abc123...';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port       = 587;

$mail->setFrom('you@yourdomain.com', 'Your App');
$mail->addAddress('user@example.com');
$mail->Subject = 'Hello from Postkit SMTP';
$mail->isHTML(true);
$mail->Body = '<h1>It works!</h1><p>Sent via SMTP relay.</p>';

$mail->send();

Port 465 uses implicit TLS (the connection is encrypted from the start). Port 587 uses STARTTLS (the connection upgrades to TLS after connecting). Both are fully encrypted -- choose whichever your application or framework supports.

SMTP vs REST API

Both methods deliver emails through the same infrastructure with the same DKIM signing and tracking. Choose based on your application's needs:

FeatureREST APISMTP Relay
Batch sendingYes (up to 100 recipients)No (one message per connection)
SchedulingYes (send_at parameter)No
CancellationYes (scheduled emails)No
IdempotencyYes (Idempotency-Key header)No
TemplatesYes (server-side Handlebars)No (compose in your app)
Webhook eventsYesYes
DKIM signingYesYes
Open/click trackingYesYes

The REST API gives you batch sending, scheduling, cancellation, and idempotency. SMTP is for applications that already use SMTP and do not want to rewrite their email sending layer.

Troubleshooting

Authentication failed -- Verify your API key is correct and active. Use the full key (starting with pk_live_ or pk_test_) as both username and password.

Connection timeout -- Ensure your network allows outbound connections on port 587 or 465. Some hosting providers block outbound SMTP by default.

TLS errors -- Make sure your application supports TLS 1.2 or higher. Older TLS versions are not accepted.

What's next?