Email

The mail keyword sets up an email transport for sending emails via SMTP.

Basic Setup

mail "smtp.gmail.com" 587:
  user "you@gmail.com"
  pass "app-password"

This creates a mail object you can use to send emails anywhere in your code.

With Environment Variables

Keep credentials out of your code:

env:
  str MAIL_USER required
  str MAIL_PASS required

mail "smtp.gmail.com" 587:
  user env.MAIL_USER
  pass env.MAIL_PASS

Sending Email

Use the mail.send() method:

# In a server route
server app port 3000:
  post "/contact":
    mail.send(body.email, "Thanks!", "We received your message.")
    ret {sent: true}

Syntax

mail "host" port:
  user <expression>    # SMTP username
  pass <expression>    # SMTP password

Multi-Target

Target Library
Node.js / Bun nodemailer
Python smtplib + email.mime (stdlib)