Skip to content

SMTP Setup

Configure your application to send emails through the Mail.td sandbox. Only SMTP credentials change — your application code stays the same.

Credentials

SettingValue
Hostsmtp.mail.td
Port587 (recommended) — also supports 25, 465, 2525
Auth methodPLAIN
Usernameany value (e.g. sandbox)
Passwordyour Pro API token (td_...)

TIP

Create an API token in Pro Dashboard → API Tokens. Use the full token string (starting with td_) as the SMTP password.

Code examples

Node.js (Nodemailer)

javascript
const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
  host: "smtp.mail.td",
  port: 587,
  auth: {
    user: "sandbox",
    pass: process.env.MAILTD_TOKEN, // td_...
  },
});

await transporter.sendMail({
  from: "dev@yourapp.com",
  to: "user@example.com",
  subject: "Welcome to MyApp",
  html: "<h1>Hello!</h1><p>Thanks for signing up.</p>",
});

Python (smtplib)

python
import smtplib
from email.mime.text import MIMEText
import os

msg = MIMEText("<h1>Hello!</h1><p>Thanks for signing up.</p>", "html")
msg["Subject"] = "Welcome to MyApp"
msg["From"] = "dev@yourapp.com"
msg["To"] = "user@example.com"

with smtplib.SMTP("smtp.mail.td", 587) as server:
    server.login("sandbox", os.environ["MAILTD_TOKEN"])
    server.send_message(msg)

Go (net/smtp)

go
package main

import (
    "net/smtp"
    "os"
)

func main() {
    auth := smtp.PlainAuth("", "sandbox", os.Getenv("MAILTD_TOKEN"), "smtp.mail.td")

    msg := []byte("From: dev@yourapp.com\r\n" +
        "To: user@example.com\r\n" +
        "Subject: Welcome to MyApp\r\n" +
        "Content-Type: text/html\r\n\r\n" +
        "<h1>Hello!</h1><p>Thanks for signing up.</p>")

    smtp.SendMail("smtp.mail.td:587", auth, "dev@yourapp.com",
        []string{"user@example.com"}, msg)
}

PHP (PHPMailer)

php
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host       = 'smtp.mail.td';
$mail->SMTPAuth   = true;
$mail->Username   = 'sandbox';
$mail->Password   = getenv('MAILTD_TOKEN');
$mail->Port       = 587;

$mail->setFrom('dev@yourapp.com');
$mail->addAddress('user@example.com');
$mail->Subject = 'Welcome to MyApp';
$mail->isHTML(true);
$mail->Body = '<h1>Hello!</h1><p>Thanks for signing up.</p>';

$mail->send();

Ruby (Net::SMTP)

ruby
require "net/smtp"

message = <<~MSG
  From: dev@yourapp.com
  To: user@example.com
  Subject: Welcome to MyApp
  Content-Type: text/html

  <h1>Hello!</h1><p>Thanks for signing up.</p>
MSG

Net::SMTP.start("smtp.mail.td", 587, "localhost", "sandbox",
                ENV["MAILTD_TOKEN"], :plain) do |smtp|
  smtp.send_message(message, "dev@yourapp.com", ["user@example.com"])
end

Java (Jakarta Mail)

java
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.mail.td");
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");

Session session = Session.getInstance(props, new Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication("sandbox",
            System.getenv("MAILTD_TOKEN"));
    }
});

Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("dev@yourapp.com"));
msg.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse("user@example.com"));
msg.setSubject("Welcome to MyApp");
msg.setContent("<h1>Hello!</h1><p>Thanks for signing up.</p>", "text/html");

Transport.send(msg);

Framework configuration

Laravel (.env)

MAIL_MAILER=smtp
MAIL_HOST=smtp.mail.td
MAIL_PORT=587
MAIL_USERNAME=sandbox
MAIL_PASSWORD=td_your_token_here
MAIL_FROM_ADDRESS=dev@yourapp.com

Django (settings.py)

python
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.mail.td"
EMAIL_PORT = 587
EMAIL_HOST_USER = "sandbox"
EMAIL_HOST_PASSWORD = os.environ["MAILTD_TOKEN"]

Rails (config/environments/development.rb)

ruby
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: "smtp.mail.td",
  port: 587,
  user_name: "sandbox",
  password: ENV["MAILTD_TOKEN"],
  authentication: :plain,
}

Environment variables

We recommend using environment variables to switch between sandbox (dev) and production SMTP:

bash
# Development / CI
export SMTP_HOST=smtp.mail.td
export SMTP_PORT=587
export SMTP_USER=sandbox
export SMTP_PASS=td_your_token_here

# Production
export SMTP_HOST=smtp.sendgrid.net
export SMTP_PORT=587
export SMTP_USER=apikey
export SMTP_PASS=SG.your_sendgrid_key

Your application reads these variables and the same code works in both environments.

Troubleshooting

Connection refused

If port 587 is not available, try one of the alternative ports:

PortWhen to use
587Default, works on most networks
2525Alternative when 587 is blocked
465Use for implicit TLS connections
25Standard SMTP, but blocked by many cloud providers

Authentication failed (535)

  • Verify the token starts with td_.
  • Check the token hasn't been revoked in Pro Dashboard → API Tokens.
  • Ensure your Pro subscription is active (not downgraded).

Emails not appearing in dashboard

  • Confirm you received 250 OK after the DATA command.
  • Check the SMTP Sandbox page in Pro Dashboard — emails appear within seconds.
  • If using a library that pools connections, ensure the AUTH happens on each new connection.

Mail.td API Documentation