Send over SMTP

Send App email from any mail library through smtp.daster.io with your project ID and a key.

Last updated

Apps that can only send through SMTP, such as a framework's mailer or a WordPress mail plugin, can use DASTER's SMTP server. A message sent this way goes through the same queue as the HTTP API: the same caps, suppressions, sender domain checks and Delivery logs.

App email › Settings shows these values on its SMTP card.

SettingValue
Hostsmtp.daster.io
Port465 with TLS from the start, or 587 with STARTTLS
UsernameYour project ID
PasswordA project key that can send email (daster_sk_…), see Keys
AuthPLAIN or LOGIN

TLS is required on both ports. On 587, DASTER refuses AUTH and MAIL until the client has sent STARTTLS. Port 25 is not offered.

Keys

The password is the project's server key, or a narrower key you create under App email › Settings with Sending access (see App email). Older daster_comm_… keys with email access also work. A browser key (daster_pk_…) is refused.

Keep the key on your server, like any server key.

What a message may contain

DASTER reads the message the way a normal mail library writes it:

  • From and To with or without display names, an encoded subject, folded headers, Date and Message-ID;
  • a text part, an HTML part or both. An HTML-only message gets a text part made from the HTML;
  • one Reply-To address;
  • other headers, which are read and dropped.

These are refused with a 554 reply that says why:

  • more than one recipient, or any Cc or Bcc. Send one message per recipient, or use the HTTP API;
  • attachments. Use the HTTP API, which takes up to 10;
  • a From header that is not the MAIL FROM address, or a To header that is not the RCPT TO address;
  • a subject over 200 characters, text over 16,000 characters or HTML over 32,000 characters;
  • a message over 256 KiB.

The From address must be on a verified sender domain of the project.

Retries

If the connection drops after you sent a message, your library may send it again. DASTER uses the message's Message-ID as its retry key, so the same message is sent once. To choose the key yourself, add the header X-Daster-Idempotency-Key (1 to 128 letters, digits, _ or -). A message with neither header is always a new message.

A 451 reply means the message was not taken this time: retry it later with the same key.

Nodemailer (Node.js)

JavaScript
import nodemailer from 'nodemailer';

const transport = nodemailer.createTransport({
  host: 'smtp.daster.io',
  port: 587,
  secure: false,
  requireTLS: true,
  auth: {
    user: process.env.DASTER_PROJECT_ID,
    pass: process.env.DASTER_EMAIL_KEY,
  },
});

await transport.sendMail({
  from: 'Northwind <hello@example.com>',
  to: 'user@example.com',
  subject: 'Welcome',
  text: 'Thanks for signing up.',
  html: '<p>Thanks for signing up.</p>',
});

Nodemailer writes a Message-ID for every message, so a resend after a dropped connection is sent once. Use port: 465 with secure: true for TLS from the start.

Python smtplib

PYTHON
import os
import smtplib
import ssl
from email.message import EmailMessage
from email.utils import make_msgid

msg = EmailMessage()
msg["From"] = "Northwind <hello@example.com>"
msg["To"] = "user@example.com"
msg["Subject"] = "Welcome"
msg["Message-ID"] = make_msgid(domain="example.com")
msg.set_content("Thanks for signing up.")
msg.add_alternative("<p>Thanks for signing up.</p>", subtype="html")

with smtplib.SMTP_SSL("smtp.daster.io", 465, context=ssl.create_default_context()) as smtp:
    smtp.login(os.environ["DASTER_PROJECT_ID"], os.environ["DASTER_EMAIL_KEY"])
    smtp.send_message(msg)

EmailMessage does not add a Message-ID by itself, so the example sets one. For port 587, use smtplib.SMTP("smtp.daster.io", 587) and call smtp.starttls(context=ssl.create_default_context()) before login.

Limits

LimitValue
Recipients per message1
Message size256 KiB
Messages per project60 a minute, and the App email limits
Connections per address5 at a time (200 for the whole server)
Sign-in attempts per address10 in 15 minutes; after 5 failures, wait 15 minutes
Idle connectionClosed after 15 seconds without a command

A wrong username or key answers 535 5.7.8 Invalid project credential. Every successful sign-in is written to the audit log; failed ones are only counted.