Default
email-message
Creates a new empty email message object that can be configured with headers, body, and attachments.
(none)
returns native gomail-message object for building email content
msg: email-message
equal { msg |type? } 'native
gomail-message//Set-header
Sets a standard email header field such as Subject, To, From, Cc, or Bcc with the specified value.
message Native gomail-message object
field String or Tagword representing header name (e.g., "Subject", 'to, 'from)
value String or Email containing the header value
returns the message object for method chaining
msg: email-message
msg .Set-header "Subject" "Test Email"
msg .Set-header 'to "user@example.com"
error { msg .Set-header "Subject" 123 }
gomail-message//Set-address-header
Sets an email address header with both email address and display name, commonly used for From, To, Cc, and Bcc fields.
message Native gomail-message object
field String header field name (e.g., "From", "To", "Cc", "Bcc")
address String email address
name String display name for the email address
returns the message object for method chaining
gomail-message//Set-body
Sets the main body content of the email with the specified MIME content type, supporting plain text and HTML formats.
message Native gomail-message object
contentType String MIME content type (e.g., "text/plain", "text/html")
content String containing the email body content
returns the message object for method chaining
gomail-message//Attach
Attaches a file to the email message using a file URI, making the file available as an email attachment.
message Native gomail-message object
file Uri pointing to the file to attach (must use file
returns the message object for method chaining
gomail-message//Add-alternative
Adds alternative content to the email (e.g., HTML version alongside plain text), allowing email clients to choose their preferred format.
message Native gomail-message object
contentType String MIME content type for the alternative content
content String containing the alternative body content
returns the message object for method chaining
new-email-dialer
Creates a new SMTP dialer configured with server details and authentication credentials for sending emails.
server String SMTP server hostname (e.g., "smtp.gmail.com", "mail.example.com")
port Integer SMTP port number (commonly 25, 465, 587, or 2525)
username String username for SMTP authentication
password String password for SMTP authentication
returns native gomail-dialer object configured for sending emails
gomail-dialer//Dial-and-send
Connects to the SMTP server and sends the specified email message, handling authentication and delivery.
dialer Native gomail-dialer object configured with SMTP settings
message Native gomail-message object containing the email to send
returns the dialer object on success, or error object if sending fails
Email parsing functions
reader//Parse-email
Parses email data from a reader.
reader native reader object containing email data
returns native parsed-email object
equal { reader %email.eml |parse-email |type? } 'native
equal { reader %email.eml |parse-email |kind? } 'parsed-email
parsed-email//Subject?
Gets the subject from a parsed email.
email native parsed-email object
returns string containing the email subject
equal { reader %email.eml |parse-email |subject? |type? } 'string
parsed-email//Message-id?
Gets the message ID from a parsed email.
email native parsed-email object
returns string containing the email message ID
equal { reader %email.eml |parse-email |message-id? |type? } 'string
parsed-email//Html-body?
Gets the HTML body from a parsed email.
email native parsed-email object
returns string containing the HTML body of the email
equal { reader %email.eml |parse-email |html-body? |type? } 'string
parsed-email//Text-body?
Gets the plain text body from a parsed email.
email native parsed-email object
returns string containing the plain text body of the email
equal { Reader %email.eml |parse-email |text-body? |type? } 'string
parsed-email//Attachments?
Gets the attachments from a parsed email.
email native parsed-email object
returns native object containing email attachments
parsed-email//Embedded-files?
Gets the embedded files from a parsed email.
email native parsed-email object
returns native object containing embedded files from the email
Default
imap-client
Create new IMAP client connection with username, password, server, and port.
username String - IMAP username
password String - IMAP password
server String - IMAP server hostname (e.g., "imap.gmail.com")
port Integer - IMAP server port (usually 993 for SSL, 143 for plain)
returns Native imap-client object on successError on connection failure
imap-client\oauth2
Create new IMAP client connection with OAuth2 authentication (email, access_token, server, port).
email String - Email address for OAuth2 authentication
access_token String - OAuth2 access token
server String - IMAP server hostname (e.g., "imap.gmail.com")
port Integer - IMAP server port (usually 993 for SSL)
returns Native imap-client object on successError on connection failure
imap-client//Select-folder
Select a folder for operations (e.g., 'INBOX').
client Native imap-client object
folder String - Folder name (e.g., "INBOX", "Sent", "Drafts")
returns Native imap-client object (for method chaining)Error if folder selection fails
imap-client//Get-folders
Get list of available folders.
client Native imap-client object
returns Block of strings containing folder names (e.g., ["INBOX", "Sent", "Drafts"])Error if retrieval fails
imap-client//Search-emails
Search for emails using IMAP search criteria (e.g., 'UNSEEN', 'FROM "user@domain.com"', 'SUBJECT "test"').
client Native imap-client object
search_criteria String - IMAP search criteria (e.g., "UNSEEN", "FROM "user@domain.com"", "SUBJECT "test"", "SINCE "01-Jan-2023"")
returns Block of integers containing matching email UIDsError if search fails
imap-client//Get-overviews
Get email overviews (headers only, fast) for given UIDs block.
client Native imap-client object
uids Block of integers containing email UIDs to fetch overviews for
returns Block of dictionaries with email overview information (uid, subject, from, to, date, size, flags)Error if retrieval fails
imap-client//Get-emails
Get full emails with bodies and attachments (slower) for given UIDs block.
client Native imap-client object
uids Block of integers containing email UIDs to fetch full content for
returns Block of dictionaries with complete email information (uid, subject, from, to, cc, bcc, date, received, message-id, size, text, html, flags, attachments)Error if retrieval fails
Default
smtp-server
Creates a new SMTP server that can receive incoming email messages on the specified address.
address String containing the server address (e.g., "
returns native smtpd object configured to listen on the specified address
smtpd//Serve
Starts the SMTP server listening for incoming emails and calls the handler function for each received message.
server Native smtpd object created by smtp-server
handler Function that processes incoming emails (reader from to origin -> ...)
appname String name for the SMTP server application
password String password for SMTP authentication (empty string for no auth)
returns the server object after starting to listen, or error if unable to serve
handler: fn { reader from to origin } { print "Got email from:" from }
smtp-server ":2525"
|Serve handler "TestSMTP" ""