SMTP Quickstart
This guide configures the Mailtarget SMTP relay and verifies one delivery from your terminal. About five minutes if your sending domain is verified.
Connection settings
Host: smtp.mtrgt.net
Port: 587
Encryption: STARTTLS
Username: smtp_mt_injection
Password: <api_key with Send via SMTP permission>
The username is fixed for every account. The password is your API key. Create the key in the dashboard and grant it the Send via SMTP permission. Read Authentication for permission scope details.
Quick verification with swaks
swaks is the standard tool for verifying SMTP from a terminal. Install it with your package manager (brew install swaks on macOS, apt install swaks on Debian or Ubuntu).
swaks \
--to recipient@example.com \
--from you@your-verified-domain.com \
--server smtp.mtrgt.net:587 \
--tls \
--auth LOGIN \
--auth-user smtp_mt_injection \
--auth-password "$MAILTARGET_API_KEY" \
--header "Subject: SMTP test from Mailtarget" \
--body "If you can read this, the relay works."
A successful run ends with the relay returning a 250 Ok status and a queued message ID.
Configuring an existing application
Most applications expose the same five fields. Map them to the values above.
Postfix
relayhost = [smtp.mtrgt.net]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
The sasl_passwd file contains:
[smtp.mtrgt.net]:587 smtp_mt_injection:<api_key>
Run postmap /etc/postfix/sasl_passwd and systemctl reload postfix after writing the file.
WordPress (WP Mail SMTP plugin)
In WP Mail SMTP, Settings, choose Other SMTP and enter:
- SMTP Host:
smtp.mtrgt.net - SMTP Port:
587 - Encryption:
TLS(the plugin uses "TLS" to mean STARTTLS on port 587) - Authentication: enabled
- SMTP Username:
smtp_mt_injection - SMTP Password: your API key
Java (Spring Boot)
spring:
mail:
host: smtp.mtrgt.net
port: 587
username: smtp_mt_injection
password: ${MAILTARGET_API_KEY}
properties:
mail.smtp.auth: true
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
Node.js (Nodemailer)
import nodemailer from "nodemailer";
const transport = nodemailer.createTransport({
host: "smtp.mtrgt.net",
port: 587,
secure: false, // STARTTLS, not implicit TLS
requireTLS: true,
auth: {
user: "smtp_mt_injection",
pass: process.env.MAILTARGET_API_KEY,
},
});
await transport.sendMail({
from: '"Your Name" <you@your-verified-domain.com>',
to: "recipient@example.com",
subject: "SMTP test from Mailtarget",
text: "If you can read this, the relay works.",
});
Common SMTP errors
| Error text | Likely cause | Fix |
|---|---|---|
535 Authentication failed | Wrong username or password. | Username must be smtp_mt_injection. Password is the API key with Send via SMTP permission. |
550 Sender domain not verified | The From address is on a domain that has not been verified. | Verify the domain. See Sending Domains. |
550 Recipient on suppression list | The recipient is on the account suppression list. | Use a different test recipient. |
421 Connection rate exceeded | Too many concurrent SMTP connections from one source. | Reduce concurrency at the application layer. |
530 Must issue STARTTLS first | The connection is not upgrading to TLS. | Enable STARTTLS in the client (the --tls flag in swaks, requireTLS: true in Nodemailer). |
For the full error catalog including SMTP response codes, read Errors and Rate Limits.
What is next
The SMTP relay accepts the message at submit time, but the final delivery state arrives via webhook. Wire Webhooks before going to production. Without webhooks, you have no way to detect bounces, complaints, or unsubscribes.
If you decide later that you want server-side templates, structured metadata, or per-recipient substitution data, switch to the API path. Read API vs SMTP for the comparison and API Quickstart for the migration.