SMTP sandbox
Point your app’s SMTP settings here. Every email it sends is stored in your sandbox, where you can open it or read it through the API. Nothing is delivered to the real recipients. If you have used Mailpit or MailHog, this is the same idea, hosted.
A sandbox needs a free account. You get the username and password when you create it.
Settings
Set up your app
Keep the username and password in environment variables, and use these settings only in development, CI and staging.
import nodemailer from 'nodemailer';
const transport = nodemailer.createTransport({
host: 'smtp.mail7.app',
port: 2525,
secure: false, // this port has no TLS
auth: { user: process.env.MAIL7_SMTP_USER, pass: process.env.MAIL7_SMTP_PASS },
});
await transport.sendMail({
from: 'App <app@example.test>',
to: 'anyone@example.test', // captured, never delivered
subject: 'Welcome',
html: '<p>Your code is <b>482913</b></p>',
});EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.mail7.app"
EMAIL_PORT = 2525
EMAIL_HOST_USER = os.environ["MAIL7_SMTP_USER"] # sbx_…
EMAIL_HOST_PASSWORD = os.environ["MAIL7_SMTP_PASS"] # m7s_…
EMAIL_USE_TLS = False
EMAIL_USE_SSL = FalseMAIL_MAILER=smtp
MAIL_HOST=smtp.mail7.app
MAIL_PORT=2525
MAIL_USERNAME=sbx_…
MAIL_PASSWORD=m7s_…
MAIL_ENCRYPTION=nullconfig.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.mail7.app",
port: 2525,
user_name: ENV["MAIL7_SMTP_USER"],
password: ENV["MAIL7_SMTP_PASS"],
authentication: :plain,
enable_starttls_auto: false
}spring.mail.host=smtp.mail7.app
spring.mail.port=2525
spring.mail.username=${MAIL7_SMTP_USER}
spring.mail.password=${MAIL7_SMTP_PASS}
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=falsepackage main
import (
"net/smtp"
"os"
)
// net/smtp's PlainAuth refuses to log in without TLS unless the host is localhost.
// This auth does the same PLAIN exchange without that check. Use it for the sandbox only.
type sandboxAuth struct{ user, pass string }
func (a sandboxAuth) Start(*smtp.ServerInfo) (string, []byte, error) {
return "PLAIN", []byte("\x00" + a.user + "\x00" + a.pass), nil
}
func (a sandboxAuth) Next([]byte, bool) ([]byte, error) { return nil, nil }
func main() {
auth := sandboxAuth{os.Getenv("MAIL7_SMTP_USER"), os.Getenv("MAIL7_SMTP_PASS")}
msg := []byte("From: app@example.test\r\nTo: anyone@example.test\r\nSubject: Welcome\r\n\r\nYour code is 482913\r\n")
err := smtp.SendMail("smtp.mail7.app:2525", auth, "app@example.test", []string{"anyone@example.test"}, msg)
if err != nil {
panic(err)
}
}# swaks
swaks --server smtp.mail7.app:2525 \
--auth PLAIN --auth-user sbx_… --auth-password m7s_… \
--from app@example.test --to anyone@example.test \
--header "Subject: Welcome" --body "Your code is 482913"
# curl, sending a file
curl smtp://smtp.mail7.app:2525 --user 'sbx_…:m7s_…' \
--mail-from app@example.test --mail-rcpt anyone@example.test \
--upload-file mail.emlNo SMTP? Post the message over HTTPS
Send a raw email (RFC 822, a .eml file) as the request body. It lands in the sandbox like a message sent over SMTP. This path is encrypted and uses your API key.
curl -X POST https://api.mail7.app/v1/inboxes/sbx_…/messages \
-H "Authorization: Bearer m7_…" \
--data-binary @mail.emlRead what was captured
Open the sandbox in the Mail window to see each message as HTML, text, raw source, headers and links. New mail shows up as it arrives. From a test, wait for the message and assert on it:
curl "https://api.mail7.app/v1/inboxes/sbx_…/wait?timeout=30&subject=Welcome" \
-H "Authorization: Bearer m7_…"
# {"subject":"Welcome","to":["anyone@example.test"],"otp":"482913", …}to lists every recipient your app named, so you can check who would have got the email. More in the API docs.
How the server behaves
- Every recipient is accepted, up to 100 per message. No address is checked and nothing is sent on.
- You must log in before sending. A wrong username or password gets
535. - Messages can be up to 5 MB. Bigger ones get
552. - A sandbox keeps its newest 200 messages, for 7 days. Older ones are removed.
- You can send several messages on one connection. A connection that is silent for 60 seconds is closed.
STARTTLSis answered with502. If your client insists on it, turn it off in the client.