Sending email from a machine
A machine can’t send mail over SMTP. Send it through your mail provider’s HTTPS API
instead: every transactional mail service has one, and a machine reaches HTTPS (port 443)
like any other web API.
What is blocked
- Ports
25,465and587are always blocked, in every region and for every machine, whatever else the machine may reach. A connection to them times out; it isn’t refused. - Port
2525is blocked too in some regions, by the hosting provider’s network. Don’t rely on it, or on any other SMTP port. - Everything else outbound works as before: HTTPS, SSH, databases, other ports.
Machines send from the address of the host they run on, shared with other machines. Mail from one of them that got marked as spam would put every machine on that host on a blocklist, which is why SMTP stays closed.
Use your provider’s HTTPS API
Most providers that offer SMTP relay also offer an HTTP API for the same account, with the same sending domain and reports: Postmark, SendGrid, Mailgun, Amazon SES, Brevo, Resend, AhaSend and others. Most mail libraries and frameworks have an adapter for them (Swoosh, Action Mailer, Django’s email backends, Nodemailer’s transports): switch the transport from SMTP to the provider’s API, and the rest of your app stays as it is.
Keep the API key as a credential, bound to the provider’s API host and
the header it expects (usually Authorization). The region’s credential service then adds
it to the machine’s requests to that host, and nothing in the machine sees the key. Mark it
readable in the machine only if your library insists on holding the key itself.
Testing
A connection test shows the difference:
nc -vz -w 5 smtp.example.com 587 # times out: blocked
nc -vz -w 5 api.example.com 443 # succeedsIf your app needs SMTP and has no way around it, tell us: Feedback in the portal,
space bugreport --feature, or space-env bugreport --feature from the machine. Say which provider
and why.