Skip to content
Browse docs

Sending email from a server

Agent Servers cannot send email directly. Outbound connections to mail servers on TCP ports 25, 465, 587 are blocked, so a mail client, a local mail server or an SMTP library on the server gets a refused connection straight away. Receiving connections and everything on the server itself (localhost) are not affected.

Use an email API instead

Send through a transactional email service over HTTPS (port 443), which is open. Each has a Node.js and Python SDK and a free or low-cost starting tier:

  • Resend: an HTTP API and SDKs built for developers.
  • Postmark: transactional email with strong delivery.
  • Amazon SES: the AWS email service, called through the AWS SDK over HTTPS.

Keep the API key in an environment variable or a secrets file, not in the repository. Use the service's HTTP API rather than its SMTP relay: the relay listens on the blocked ports too.

Why it is blocked

Direct SMTP from cloud machines is the most common source of spam, and one abused machine can get the addresses of every server listed by mail providers. Blocking it by default keeps server addresses clean for everyone. The block is monitored, and a server used to send spam is suspended. Sending spam or bulk email from a server breaks the acceptable use policy, which lists everything else a server may not be used for.