Multipart MIME composer, Ed25519 RFC 8463 DKIM signer/verifier, SMTP STARTTLS/TLS client, and Resend/Postmark payloads.
Pure-Veko RFC 5322 / RFC 2045 Multipart MIME composer, RFC 6376 / RFC 8463 Ed25519-SHA256 DKIM signer and verifier, RFC 5321 SMTP client (io/Stream and TLS 1.3), and Resend/Postmark HTTPS API payload builders.
smtp_mail provides transactional and outbound email infrastructure in pure Veko with zero external C or OpenSSL dependencies:
encode-mime): Composes RFC 5322 headers (From, To, Cc, Date, Message-ID, MIME-Version) with automatic RFC 2047 UTF-8 Base64 subject encoding (=?UTF-8?B?...?=), multipart/alternative (text/plain + text/html), and multipart/mixed 76-column Base64 binary attachments.sign-dkim-ed25519, verify-dkim-ed25519): Implements RFC 6376 relaxed/relaxed header and body canonicalization paired with RFC 8463 ed25519-sha256 signatures (crypto/sha256 + crypto/x25519) and DNS TXT _domainkey record generation.send-stream, send-tls): Drives the full RFC 5321 state machine (220 -> EHLO -> AUTH PLAIN -> MAIL FROM -> RCPT TO -> DATA with RFC 5321 Section 4.5.2 dot-stuffing -> QUIT) over any io/Stream or implicit TLS 1.3 (net/tls13).to-resend-json, to-postmark-json): Formats Email messages directly into Resend and Postmark REST API JSON payloads for serverless or port-restricted environments.veko pkg add smtp_mail@1.0.0Import in .vk modules:
use [mail = smtp_mail]encode-mime or send-stream is scrubbed via sanitize-header to strip \r, \n, and NUL bytes before serialization.verify-dkim-ed25519 compares the canonicalized body SHA-256 (bh=) using crypto/sha256/ct-eq before verifying the 64-byte RFC 8032 Ed25519 signature over SHA-256(canonical_headers).Email.bcc recipients are included in RCPT TO SMTP envelope commands (and HTTPS provider JSON fields) while never being serialized into the visible encode-mime message headers.dot-stuff prefixes any body line beginning with . with an extra . before appending \r\n.\r\n, preventing premature DATA termination or SMTP smuggling.| Type | Fields | Description |
|---|---|---|
Attachment | filename str, content_type str = 'application/octet-stream', data bytes | Binary or text file attachment. |
Email | from str, to block[str], cc block[str] = [], bcc block[str] = [], subject str, text_body str = '', html_body str = '', headers map[str] = {}, attachments block = [] | Complete email message specification. |
| Signature | Description |
|---|---|
sanitize-header = fn [s str] str | Strips \r, \n, and \0 to prevent header injection. |
encode-subject-rfc2047 = fn [subject str] str | Encodes non-ASCII subjects as =?UTF-8?B?...?=. |
extract-envelope-addr = fn [addr str] str | Extracts user@domain from 'Name <user@domain>'. |
encode-mime = fn [email Email /at unix_sec i64 = -1] str | Serializes email into RFC 5322 / RFC 2045 CRLF MIME text. |
canonicalize-body-relaxed = fn [body str] str | Applies RFC 6376 Section 3.4.4 relaxed body canonicalization. |
canonicalize-header-relaxed = fn [name str, value str] str | Applies RFC 6376 Section 3.4.2 relaxed header canonicalization. |
dkim-dns-record = fn [selector str, domain str, ed25519_pubkey bytes] map[str] | Builds the <selector>._domainkey.<domain> DNS TXT record. |
sign-dkim-ed25519 = fn [mime_msg str, domain str, selector str, ed25519_seed bytes /at unix_sec i64 = -1] str | Signs mime_msg and prepends DKIM-Signature: v=1; a=ed25519-sha256; .... |
verify-dkim-ed25519 = fn [signed_mime str, ed25519_pubkey bytes] bool | Verifies both bh= body SHA-256 and Ed25519 header signature. |
dot-stuff = fn [mime_str str] str | Applies RFC 5321 Section 4.5.2 dot-stuffing and appends \r\n.\r\n. |
send-stream = fn [mut stream io/Stream, helo_host str, auth_user str, auth_pass str, email Email /raw raw_msg str = ''] map | Delivers email (or pre-signed raw_msg) over any io/Stream. |
send-tls = fn [host str, port i64, helo_host str, auth_user str, auth_pass str, email Email /raw raw_msg str = ''] map | Connects over net/tls13 (port 465 SMTPS) and delivers email. |
to-resend-json = fn [email Email] str / to-postmark-json = fn [email Email] str | Builds JSON request bodies for Resend and Postmark HTTPS APIs. |
use [mail = smtp_mail, hex = codec/hex]
email = mail/Email {
from = 'Veko Auth <no-reply@veko-lang.org>'
to = ['user@example.com']
subject = 'Your security verification link'
text_body = 'Open https://veko-lang.org/verify to continue.\n'
html_body = '<p>Open <a href="https://veko-lang.org/verify">Verify Account</a>.</p>\n'
attachments = [
(mail/Attachment {
filename = 'receipt.txt'
content_type = 'text/plain'
data = (bytes/from-str 'Receipt #4092\n')
})
]
}
mime = mail/encode-mime email
seed = hex/decode (os/getenv/or 'DKIM_ED25519_SEED_HEX' ['0000000000000000000000000000000000000000000000000000000000000000'])
signed = mail/sign-dkim-ed25519 mime 'veko-lang.org' 's2026' seed
// Deliver via implicit TLS 1.3 (port 465)
res = mail/send-tls/raw/or 'smtp.example.com' 465 'app.veko-lang.org' 'smtp-user' 'smtp-pass' email signed [e ->
println `SMTP delivery failed: {mold e}`
return e
]
println `Queued for {res.recipients} recipient(s)`veko check packages/smtp_mail/src/mod.vk
veko check packages/smtp_mail/examples/demo.vk
veko run -C all packages/smtp_mail/examples/demo.vkhttps://veko-lang.org/pkg/smtp_mail/1.0.0.vkp6290d454bfbe06bd5098fc6d4b641bc5e11737a4fc5fc034aabf605cf077f6b77944e6baa00446d1b8b15bccdd93332929b7afcc74f0e357e3ca9ad0e5546a1eed25519:27406074d8681da1d4e6420f5d887cac15c313334c249ac047ba9d4e2df72b70{"name":"smtp_mail","version":"1.0.0","tier":1.0,"tier_label":"Tier 1: Backend Essentials","category":"Transactional Email & DKIM","description":"Multipart MIME composer, Ed25519 RFC 8463 DKIM signer/verifier, SMTP STARTTLS/TLS client, and Resend/Postmark payloads.","modules":["smtp_mail"],"homepage":"https://veko-lang.org/packages/smtp_mail"}| Bundle Entry Path | Size | Leaf SHA-256 Digest |
|---|---|---|
| README.md | 6 KB | 2e6e7d8714cb0cc7f9d81c23628aa747515a46d5537e1a7cae0e9cffc8187e8c |
| examples/demo.vk | 8 KB | 946e3a96ed3078e07005f48ddf6fe6768a14a1ba925e57ce1418df3fc06d5309 |
| mod.vk | 24 KB | 99920dec2347239d72f7504d9043b7022841ed1d768a30fc9665af1445b0f913 |