Mail Functions
This module contains functions for sending e-mail from XQuery. It is based on Jakarta Mail and its reference implementation Angus Mail.
Conventions
The module must be installed in the repository before it can be used. The version that matches BaseX is retrieved from the BaseX Maven Repository:
REPO INSTALL mail
In order to use it, it needs to be imported in the header of the query:
import module namespace mail = 'http://basex.org/modules/mail';
All functions in this module are assigned to the http://basex.org/modules/mail namespace, which in the following is assumed to be bound to the mail prefix.
Updated: Errors are assigned to the module namespace.
Errors are assigned to the module namespace; their messages are prefixed with Mail: . The codes are mail:options (missing or inconsistent options), mail:not-found (missing attachment), mail:address (invalid address), mail:connect (connection failure), mail:auth (authentication failure) and mail:error (other errors).
Functions
mail:send
Updated: Based on Jakarta Mail; stricter SSL/TLS and authentication checks. Options html, headers, bounce and timeout added. Attachments can be supplied as data and as file URIs. Sending is aborted when the query is stopped.
| Signature | mail:send( $options as map(*)) as empty-sequence() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Summary |
Sends an e-mail. The $options map carries both the SMTP connection settings and the message contents. The following keys are recognized:
The message body is encoded as UTF-8. Each address and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Examples | Sends a plain-text e-mail via an authenticated SMTP server. |
Changelog
Version 14.0- Updated:
mail:send: Based on Jakarta Mail; stricter SSL/TLS and authentication checks. Optionshtml,headers,bounceandtimeoutadded. Attachments can be supplied as data and as file URIs. Sending is aborted when the query is stopped. - Updated: Conventions: Errors are assigned to the module namespace.