smtp-gateway
SMTP Gateway (Inbound Email)
What This Is
An SMTP gateway is an off-chain mail server that accepts email addressed to a canister and delivers it by calling the canister's smtp_request method, the way the HTTP gateway calls http_request. DFINITY operates the gateways that mail for <canister-id>.icp0.io reaches, alongside its HTTP gateways; others can run their own, since the gateway is part of ic-gateway. The limits and sender checks in this skill are those of DFINITY's gateways. A canister opts in by implementing two methods. There is nothing to register for <canister-id>.icp0.io addresses. Mail flows in only: a canister cannot send email through the gateway, and it never receives bounce messages either, because the gateway rejects the null sender (MAIL FROM:<>).
The protocol is specified in candid/smtp_gateway.did in dfinity/ic-smtp-gateway-protocol, and the gateway that implements it is the smtp module of dfinity/ic-bn-lib.
Addressing
| Address | Setup |
|---|---|
anything@<canister-id>.icp0.io |
None. Every <canister-id>.icp0.io already has MX records pointing at the gateway. |
anything@<custom-domain> |
The domain must be registered as an IC custom domain (custom-domains skill): the gateway resolves it in the same registry as the HTTP gateway. Its MX records must also point at the gateway. A subdomain set up the standard way (CNAME to <domain>.icp1.io) inherits the gateway's MX records through the CNAME. An apex domain cannot be a CNAME, and ALIAS or CNAME flattening only produces A/AAAA records, so publish the hosts that dig +short MX boundary.dfinity.network lists as your MX records, and keep them in sync. Do not publish MX boundary.dfinity.network itself: mail servers would connect to that name's own addresses, which do not accept mail. |
How the gateway routes a recipient: