Last active
March 23, 2026 21:08
-
-
Save aterga/3550754502646ff69d9c18a7f76e064b to your computer and use it in GitHub Desktop.
Draft API for `smtp_request` endpoints for ICP canisters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Address = record { | |
| // Complete address. | |
| // | |
| // Example: "alice@example.com" | |
| serialized : text; | |
| // Index into `serialized` before the '@'. | |
| // | |
| // 8-bit index works here since RFC 5321 limits the length of the local part to 64 characters. | |
| at_start : nat8; | |
| }; | |
| // Examples: | |
| // record { name="From"; value="alice@example.com" }; | |
| // record { name="To"; value="verify@id.ai" }; | |
| // record { name="Subject"; value="Your verification code" }; | |
| // record { name="DKIM-Signature"; value="v=1; a=rsa-sha256; d=example.com; ..." }; | |
| type Header = record { | |
| name : text; | |
| // The decoded value of the header, as specified by the sender. | |
| // | |
| // Non-ascii header values must be decoded via RFC 2047 by the caller. | |
| // | |
| // Example: "José Pérez" | |
| // | |
| value : text; | |
| }; | |
| // Simple email envelope representation | |
| type Envelope = record { | |
| // The envelope sender address. | |
| // | |
| // More reliable than the "From" header, which can be easily spoofed. | |
| bounce_address : Address; | |
| // The adddresses of the envelope recipients | |
| to : vec Address; | |
| }; | |
| type Message = record { | |
| // Raw RFC 5322 headers | |
| headers : vec Header; | |
| // We do not support MIME, only simple text/plain messages, so the body is just a blob of bytes. | |
| body : blob; | |
| // This is typically not available to the email recipient, but is used by the SMTP server | |
| // to determine where to send emails. | |
| envelope : Envelope, | |
| }; | |
| type SmtpRequest = record { | |
| message : opt Message; | |
| }; | |
| type SmtpRequestError = record { | |
| code : nat64; | |
| message : text; | |
| }; | |
| // Used for logging on the SMPT adaptor side. | |
| type SmtpResponse = variant { | |
| ok : record {}; | |
| // Errors | |
| err : SmtpRequestError; | |
| }; | |
| service : { | |
| smtp_request : (SmtpRequest) -> (SmtpResponse); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment