Mail

Attributes

URI:http://www.xmlpipe.org/xpe/util/filter/mail
Type:filter
Namespace:http://www.softtouchit.com/xpe/mail
Owner:http://www.xmlpipe.org/xpe/util

Description

This filter allows XPE pipelines to send emails.

Create a mail session

To establish a mail session and send emails, the XPE pipeline needs to generate an XML fragment conforming to the following:


   <m:session  type="mail.smtp.host"  server="{$mailServer}"  username="{$mailUsername}"  password="{$mailPassword}"  xmlns:m="http://www.softtouchit.com/xpe/mail" >
      <m:mail/>
      +
   </m:session>

Sending mail

Multiple m:mail elements may be specified within a session. Each of these elements is structured as follows:


   <m:mail  from="{from email Address}"  subject="{subject}"  to="{to email address}"  xmlns:m="http://www.softtouchit.com/xpe/mail" >
      <m:body>
         <m:text>
            plain text email goes here
         </m:text>
         <m:mimePart  href="{uri to the mime address}"  mimeType="text/html; charset=utf-8" />
      </m:body>
   </m:mail>

Elements

Element nameDescription
m:session
Main outer element. This element establishes a session with a given Mail Server. The element is mandatory and may contain multiple m:mail elements.

Attributes

Attribute nameDescription
type
This attribute defines the type of mail server supplying SMTP services. XPE currently only supports: mail.smtp.host
server
The mail server providing the SMTP Service. If a SMTP server is running on the same machine as the XPE Server, then this would simply be specified as localhost.
username
This is the username used to authenticate and establish a mail session with the server
password
This is the password used to authenticate and establish a mail session with the server
m:mail
This element defines the mail message to send. Multiple such elements may be specified within the outer m:session elements to define multiple emails.

Attributes

Attribute nameDescription
from
The from address to be specifed for the message. eg: from="xpe.support@softtouchit.com"
subject
The subject to be specified for the message. eg: subject="mail question"
to
The email address to send the message to. Multiple addresses should be seperated by a semi-colon (;). eg: to="fred.flintstone@bedrock.com.it;barney.rubble@bedrock.com.it"
m:body
This element defines the body of the mail message. It is a sub-element of the m:mail element and there can be only one m:body element within a m:mail element. This element may contain an optional m:text element and optional m:mimePart element(s).
m:text
This element is used to specify any plain text message content.
m:mimePart
This optional element is used to specify mail attachements of a particular MIME type.

Attributes

Attribute nameDescription
href
This attribute specifies the URI of the mime attachment for the message.
mimeType
This attribute specifies the MIME Type defining the contents specified by the href attribute. eg: mimeType="text/html; charset=utf-8"

Example usage

The following example illustrates how the mail filter could be used within an XPE pipeline definition (xpipedef.xml) file:


   <xpipeDef  xmlns="http://www.xml.org/xml/pipe" >
      <register  uri="xslt/mailgen" >
         <xslt  href="ROOT/test/xslt/mailgen.xsl" />
      </register>
      <register  uri="mail" >
         <xpipe>
            <xnode  type="http://www.xml.org/pipe/xpe/source/http" />
            <xnode  type="xslt/mailgen" />
            <xnode  type="http://www.xmlpipe.org/xpe/util/filter/mail" />
            <xsink  type="http://www.xml.org/pipe/xpe/sink/http" >
               <property  name="method"  value="xml" />
            </xsink>
         </xpipe>
      </register>
   </xpipeDef>

If mailgen.xsl contains the following:


   <xsl:stylesheet  version="2.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
      <xsl:import  href="copy.xsl" />
      <xsl:output  method="xml" />
      <xsl:template  match="http:httpRequest" >
         <result  xmlns="" >
            <m:session  type="mail.smtp.host"  server="localhost"  username="admin"  password="adminpw"  xmlns:m="http://www.softtouchit.com/xpe/mail" >
               <m:mail  from="fred.flintstone@bedrock.com.it"  subject="lunch"  to="barney.rubble@bedrock.com.it" >
                  <m:body>
                     <m:text>
                        Don't forget lunch today Barney- attached is the menu.
                     </m:text>
                  </m:body>
                  <m:mimePart  href="http://localhost:8188/xpe/menus/lunchmenu.pdf"  mimeType="application/pdf; charset=utf-8" />
               </m:mail>
            </m:session>
         </result>
      </xsl:template>
   </xsl:stylesheet>

Then executing the pipeline will result in an email being sent containing some text and a pdf attachment.