smtp-gateway
БесплатноБез исполняемых скриптовНе проверенReceive email in an Internet Computer canister through the SMTP Gateway Protocol. Covers implementing smtp_request and smtp_request_validate, addressing…
от jiayaoqijia★ 81 звезда на GitHubОб этом скилле
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:
- If the first DNS label of the recipient's domain parses as a principal, that is the canister. Otherwise the exact domain is looked up among registered custom domains. No match:
550 5.1.1 Unknown recipient domain. - The domain arrives lowercased. The local part (
user) arrives verbatim: case,+tagsuffixes and quotes are kept. Match it case-insensitively unless you have a reason not to. The gateway rejects non-ASCII local parts itself. - Handing mail to another canister. Before calling the addressed canister, the gateway fetches
https://<canister-id>.icp0.io/.well-known/ic-smtp-canister-id. If that returns a 2xx response whose body (whitespace-trimmed) is a principal, every SMTP call goes to that principal instead. Any failure falls back to the addressed canister, and either result is cached for 10 minutes. Use this when a frontend canister owns the domain and a backend canister handles mail: with thestatic-siterecipe, add a file.well-known/ic-smtp-canister-idcontaining only the backend's canister ID to the uploaded directory (.well-known/is uploaded without extra configuration).
The Protocol
| Method | Required | When the gateway calls it |
|---|---|---|
smtp_request_validate : (SmtpRequest) -> (SmtpResponse) query |
Yes (see Pitfall 4) | Once per RCPT TO, before the message is transferred |
smtp_request : (SmtpRequest) -> (SmtpResponse) |
Yes | After DATA, once per destination canister, listing all recipients that resolved to it |
smtp_capabilities, smtp_upload_chunk, smtp_upload_commit, smtp_upload_status, smtp_upload_abort |
No | Chunked upload for messages over the ~2 MiB ingress limit. Read references/chunked-upload.md before implementing these. |
What each call carries:
| Field | smtp_request_validate |
smtp_request |
|---|---|---|
envelope |
MAIL FROM address and exactly one recipient |
MAIL FROM address and every recipient for this canister (at most 10 per session) |
message |
null |
Headers and raw body |
message_id |
null |
A new UUIDv7 for every SMTP transaction |
The wire types are defined in candid/smtp_gateway.did. The Rust crate exports them, and the Motoko example below declares them field for field. code is nat64 (a nat32 does not decode), the variant labels are exactly Ok and Err, and Ok carries an empty record, not null.
Reply Codes Are the Interface
The gateway acts on the class of SmtpRequestError.code: 500–599 is permanent and anything else is temporary. Traps and call failures are temporary too, except two that are permanent: the method is not exported, or the request is too large for one ingress message.
During RCPT TO, from smtp_request_validate:
| Canister result | The sending server sees |
|---|---|
Ok |
250 2.1.5 OK |
Err with code 550 |
550 5.1.2 Mailbox does not exist. for that recipient only (your message is dropped) |
Err with another 500–599 code |
550 5.1.3 Permanent error: <message> |
Err with any other code |
451 4.4.3 Temporary error: <message> |
| Method not exported | `550 5.1.3 Perma |
Установить smtp-gateway в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл smtp-gateway?
Receive email in an Internet Computer canister through the SMTP Gateway Protocol. Covers implementing smtp_request and smtp_request_validate, addressing (user@<canister-id>.icp0.io, custom domains, handing mail to another canister with /.well-known/ic-smtp-canister-id), how the gateway turns reply codes into SMTP (5xx bounces, everything else retries, 550 rejects one recipient), what actually arrives (raw headers, raw MIME body, a per-attempt message_id, no sender authentication), the ic-smtp-gateway-protocol Rust crate, and the optional chunked upload for messages over 2 MiB. Use when a canister must receive or process inbound email, when implementing the SMTP gateway Candid interface, or when mail to a canister bounces, is retried, or never arrives. Do NOT use for sending email from a canister (the gateway is inbound only; call an email API with https-outcalls) or for serving HTTP from a canister.
Как установить скилл smtp-gateway?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл smtp-gateway запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic