Sends an email message.
<p:declare-step type="p:send-mail"> <input port="source" primary="true" content-types="any" sequence="true"/> <output port="result" primary="true" content-types="application/xml" sequence="false"/> <option name="auth" as="map(xs:string, item()+)?" required="false" select="()"/> <option name="parameters" as="map(xs:QName, item()*)?" required="false" select="()"/> <option name="serialization" as="map(xs:QName,item()*)?" required="false" select="()"/> </p:declare-step>
The p:send-mail
step sends an email message. This message, described in the XML format for mail, must appear on
the source
port.
Ports:
Port | Type | Primary? | Content types | Seq? | Description |
---|---|---|---|---|---|
|
|
|
|
| The email message to send. The first document on this port must be an XML document describing the email message. It must conform to the XML format for mail. The Any additional documents are treated as email attachments. |
|
|
|
|
| If the email was sent successfully, this port will emit a short XML document containing just
If something went wrong during the sending operation, error |
Options:
The p:send-mail
step attempts to send an email message using SMTP. The address of the SMTP server and other details can be supplied using the Step parameters and
Authentication parameters.
The email message itself must be described using the XML format for mail. Examples can be found in the specification or in the Basic usage example below.
The parameters
option contains additional information used for constructing and sending the email message. It is a map
that associates parameters (the keys in the map) with values. The following parameters are defined:
Parameter | Datatype | Description |
---|---|---|
|
| If |
|
| The URL of the SMTP server to use. If no value for |
|
| The IP port to use when sending the mail to the SMTP server. If no value for |
Depending on the XProc processor used, the parameters
map may contain other, implementation-defined, keys.
The auth
option contains additional information used for the authentication with the SMTP server. It is a map that
associates parameters (the keys in the map) with values. The following authentication parameters are defined:
Parameter | Datatype | Description |
---|---|---|
|
| The username used for authentication. |
|
| The password used for authentication. |
Depending on the XProc processor used, the auth
map may contain other, implementation-defined, keys.
Below a very basic example of how to construct an email message and use p:send-mail
to send it. I hope I get a lot of messages like
this ;).
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0"> <p:input port="source"> <p:inline> <emx:Message xmlns:emx="URN:ietf:params:email-xml:" xmlns:rfc822="URN:ietf:params:rfc822:"> <rfc822:from> <emx:Address> <emx:adrs>mailto:someone@…</emx:adrs> <emx:name>John Doe</emx:name> </emx:Address> </rfc822:from> <rfc822:to> <emx:Address> <emx:adrs>mailto:erik@xatapult.nl</emx:adrs> <emx:name>Erik Siegel</emx:name> </emx:Address> </rfc822:to> <rfc822:subject>XProcRef is awesome</rfc822:subject> <emx:content type="text/plain" xml:space="preserve"> Hi Erik, XProcRef is awesome! Congrats and kudos! Regards, John Doe </emx:content> </emx:Message> </p:inline> </p:input> <p:output port="result"/> <p:send-mail> <p:with-option name="auth" select="map{ 'username': '…', 'password': '…' }"/> <p:with-option name="parameters" select="map{ 'send-authorization': true(), 'host': '…', 'port': … }"/> </p:send-mail> </p:declare-step>
The document appearing on the result
port only has a content-type
property. It has no other
document-properties (also no base-uri
).
Error code | Description |
---|---|
It is a dynamic error if any key in the “ | |
It is a dynamic error if any key in the “ | |
It is a dynamic error if the first document on the | |
It is a dynamic error if the email cannot be send. |
This description of the p:send-mail
step is for XProc version: 3.1. This is a non-required step (an XProc 3.1 processor does not have to support this).
The formal specification for the p:send-mail
step can be found here.
The p:send-mail
step is part of categories:
The p:send-mail
step is also present in version:
3.0.