SMTP and API
Create SMTP and API credentials, send over SMTP, set up webhook notifications and review message logs.
Once a sending domain is verified, you can create credentials so your application can send over SMTP, then follow delivery results with webhooks and message logs. Everything on this page happens in the tabs of the subscription detail page (/tm/<subscription ID>).
Create a credential
Each credential belongs to a mail server and has one of two types:
| Type | Use |
|---|---|
| SMTP Credential | The password for SMTP authentication when you send over SMTP. |
| API Key | For sending through the API. |
Steps:
- Open the subscription detail page and go to the Credentials tab.
- Pick the mail server from the drop-down at the top, then create a credential.
- Fill in Mail Server and Credential Name (for example
Production API Key), and set Type to SMTP Credential or API Key. - After you submit, a dialog shows the new key. Copy it and store it somewhere safe right away.
The Key column in the credentials list hides keys by default. Click the eye icon to show a key or the copy icon to copy it. You can delete a credential you no longer need after confirming Delete this credential?. Any application that authenticates with it can no longer send.
A key grants permission to send as you. Don't put it in front-end code or a public repository. Keep it in server-side environment variables or a secrets manager, and give each application or environment its own credential so you can revoke them one at a time.
SMTP settings
The SMTP Settings area at the top of the Credentials tab shows the connection details for the selected mail server:
| Field | Description |
|---|---|
| Host | The SMTP server address shown in the console. |
| Port | The SMTP port shown in the console. |
| TLS | Required. The connection must be encrypted with TLS. |
| Auth | PLAIN or LOGIN. |
Authentication:
- Username: the mail server's Token, shown in the Token column of the Mail Servers tab.
- Password: the key of an SMTP Credential.
The From address must use a domain that shows as verified under Domains.
Send a test message with swaks
swaks --server <Host>:<Port> --tls \
--auth LOGIN \
--auth-user '<mail server Token>' \
--auth-password '<SMTP credential key>' \
--from noreply@example.com \
--to you@example.net \
--header 'Subject: Test from Transactional Mail' \
--body 'Hello'Configure your application (Python example)
import smtplib
from email.message import EmailMessage
msg = EmailMessage()
msg["From"] = "noreply@example.com"
msg["To"] = "you@example.net"
msg["Subject"] = "Welcome"
msg.set_content("Thanks for signing up.")
with smtplib.SMTP("<Host>", <Port>) as s:
s.starttls()
s.login("<mail server Token>", "<SMTP credential key>")
s.send_message(msg)If the port shown in the console expects TLS from the start of the connection (implicit TLS), use smtplib.SMTP_SSL and remove the starttls() call.
Send through the API
Credentials of type API Key are for sending through the API. The console doesn't show the API endpoint yet. To use the API, contact support for the endpoint address and request format.
Live and Development modes
The Mode you chose when you created the mail server changes how mail is delivered:
- Live (Production): mail is delivered to recipients normally.
- Development (Testing): for integration testing. Mail is usually not delivered to external recipients. Check the results in the Messages tab.
Before you go live, make sure your application uses credentials from a Live mail server.
Webhook notifications
A webhook sends an HTTP request to a URL you choose whenever an email event happens, so your systems can record deliveries, bounces and other status changes.
Go to the Webhooks tab, pick the mail server and create a webhook.
Enter a Webhook Name and a Webhook URL (for example
https://your-server.com/webhook).Events: turn on All Events to subscribe to every event, or turn it off and pick events under Select Events:
Event Meaning Message Sent The message was sent Message Delivered The message was delivered Message Delayed Delivery was delayed and will be retried Message Bounced The message bounced Message Held The message was held Link Clicked The recipient clicked a link in the message Domain DNS Error There's a problem with the sending domain's DNS After saving, use the test button to send a test request to the URL. When you edit a webhook, you can use the Enabled switch to pause it.
Your endpoint should return a 2xx status code quickly. Run any slow processing asynchronously in the background.
Message logs
The Messages tab shows the message log for each mail server:
- Summary at the top: Total (24h), Sent, Pending and Failed.
- Filters: status (Sent, Pending, Soft Fail, Hard Fail, Held), direction (Outgoing, Incoming) and keyword search.
- Columns: ID, Token, From, To, Subject and Status. Open a message to see its Message ID, size, creation time and delivery attempts.
- Actions: Retry a message whose status is Soft Fail or Hard Fail. Cancel a message whose status is Pending or Held.
Troubleshooting
Authentication fails: check that the username is the mail server's Token, that the password is the key of an SMTP Credential, and that the credential belongs to the same mail server.
Sender rejected: check that the From domain shows Verified under Domains.
High sending volume: Send Limit at the top of the subscription page shows your plan's hourly sending limit. If you expect to exceed it, slow your sending rate or upgrade your plan.