The BaseX Mail Module provides functions for sending e-mail from XQuery, built on Apache Commons Email. Messages are described by an XML element that carries both the SMTP connection settings and the message body.
Send a plain-text e-mail via an authenticated SMTP server:
import module namespace mail = 'http://basex.org/modules/mail';
mail:send({
'host': 'smtp.your-mail-provider.org',
'ssl': 'true',
'user': 'from@your-mail-provider.org',
'password': '...',
'from': 'from@your-mail-provider.org',
'to': 'to@your-mail-recipient.org',
'subject': 'Subject',
'message': 'Message'
})For details of the functions supported by this module, see Mail Functions in the BaseX documentation.
Pre-built module jars are available at: https://files.basex.org/modules/mail/
Download the jar matching your BaseX release and install it with:
basex -c "repo install <jar>"where <jar> must be replaced by the path to the module jar.
The prerequisites for building the module are a JDK 17 and Maven.
Use the Mail Module release whose version matches the target BaseX version. For building the module, check out the source code and run
mvn clean installThis will compile the module and leave the module jar in the target folder, as well as in the local Maven repository at ~/.m2/repository/org/basex/modules/modules-mail.
The module jar contains all required dependencies.
To install the built jar, use the repo install command shown above, replacing <jar> with the path to the generated file.
The Mail Module is provided under the BSD 3-Clause License. It depends on BaseX and Apache Commons Email, the latter transitively adding further dependencies.
An overview of the licenses of these components is available in LICENSE.txt.