Name
p:send-mail — The standard p:send-mail step.
Synopsis
The p:send-mail
step sends an email message.
Input port | Primary | Sequence | Content types |
---|---|---|---|
source | ✔ | ✔ | any |
Output port | Primary | Sequence | Content types |
---|---|---|---|
result | ✔ | application/xml |
Option name | Type | Default value |
---|---|---|
auth | map(xs:string, item()+)? | () |
parameters | map(xs:QName, item()*)? | () |
serialization | map(xs:QName,item()*)? | () |
Declaration
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
| <p:input port="source" sequence="true" content-types="any"/>
| <p:output port="result" content-types="application/xml"/>
| <p:option name="serialization" as="map(xs:QName,item()*)?"/>
5 | <p:option name="auth" as="map(xs:string, item()+)?"/>
| <p:option name="parameters" as="map(xs:QName, item()*)?"/>
|</p:declare-step>
Errors
Code | Description |
---|---|
err:XC0159 | It is a dynamic error (err:XC0159 ) if any key in
the “auth ” map is associated with a value that is not
an instance of the required type. |
err:XC0160 | It is a dynamic error (err:XC0160 ) if any key in
the “parameters ” map is associated with a value that
is not an instance of the required type. |
err:XC0161 | It is a dynamic error (err:XC0161 )
if the first document on the source port does not conform to the required format. |
err:XC0162 | It is a
dynamic error (err:XC0162 ) if the email cannot be send. |
Implementation defined features
- Other key value pairs in “
auth
” are implementation-defined - It is
implementation-defined which other
key/value pairs in the
parameters
option are supported. - Other key value pairs in “
auth
” are implementation-defined - If no values for “
host
” or “port
” is specified, it it implementation-defined which server and port is used.
Description
The p:send-mail
step is a
standard XProc 3.1 step.
It is also described on XProcRef.org.
The XML Calabash implementation of p:send-mail
relies on the
javax.mail
package to send mail. The javax.mail
package is configured with a set of
properties. There are two ways to configure the properties: with
cc:send-mail in a configuration file and with the
parameters
option. If an option is specified in both places, the
value from the parameters
option is used.
(The send-authentication
property is true by default if a username or password
is provided in the auth
parameter and false otherwise).
The following mappings apply:
p:send-mail configuration | javax.mail configuration |
---|---|
host | mail.smtp.host |
port | mail.smtp.port |
send-authentication | mail.smtp.auth |
In addition, if the debug
property is true
, javax.mail
session debugging is enabled.
Any other configuration name/value pairs are passed through unchanged.
The following configuration, for example, will send mail using GMail’s SMTP server (in September, 2025; GMail authentication may change over time):
p:send-mail configuration | Value |
---|---|
host | smtp.gmail.com |
port | 465 |
send-authentication | true |
mail.smtp.socketFactory.port | 465 |
mail.smtp.socketFactory.class | javax.net.ssl.SSLSocketFactory |
mail.smtp.fallback | false |
mail.smtp.starttls.enable | true |
You must use your full GMail address as the username
and an
application-specific password as the password
.
You might arrange for this configuration by specifying a cc:send-mail
element in your configuration:
1 |<cc:send-mail host='smtp.gmail.com' port='465'
| mail.smtp.socketFactory.port='465'
| mail.smtp.socketFactory.class='javax.net.ssl.SSLSocketFactory'
| mail.smtp.socketFactory.fallback='false'
5 | mail.smtp.starttls.enable='true'/>
And then calling p:send-mail
with only the auth
option
specifying the username and password. Or, conversely, by passing all the values in the
parameters
option:
1 |<p:send-mail
| parameters="map{'host': 'smtp.gmail.com', 'port': '465',
| 'mail.smtp.socketFactory.port': '465',
| 'mail.smtp.socketFactory.class': 'javax.net.ssl.SSLSocketFactory',
5 | 'mail.smtp.socketFactory.fallback': 'false',
| 'mail.smtp.starttls.enable': 'true'}"
| auth="map{'username':'myusername@gmail.com',
| 'password':'my-secret-app-password'}">
| <p:with-input>
10 | …
| </p:with-input>
|</p:send-mail>
Or any combination of the two that suits you.