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:
| Setting | Value |
|---|---|
| Host | mail.postkit.eu |
| Port | 587 (STARTTLS) or 465 (implicit TLS) |
| Username | Your API key (e.g., pk_live_abc123...) |
| Password | Your API key (same as username) |
| Encryption | TLS 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:
| Feature | REST API | SMTP Relay |
|---|---|---|
| Batch sending | Yes (up to 100 recipients) | No (one message per connection) |
| Scheduling | Yes (send_at parameter) | No |
| Cancellation | Yes (scheduled emails) | No |
| Idempotency | Yes (Idempotency-Key header) | No |
| Templates | Yes (server-side Handlebars) | No (compose in your app) |
| Webhook events | Yes | Yes |
| DKIM signing | Yes | Yes |
| Open/click tracking | Yes | Yes |
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?
- Domain Setup -- verify your sending domain
- DKIM, SPF & DMARC -- understand email authentication