Scenario:
If any error occurs in a message mediation flow, Administrator has to send mail to manager.
Axis configuration
To send mails, we use mail transport. Enable the 'MailTransportSender' to send emails in specific scenarios.
@axis2.xml;
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.host">smtp.gmail.com</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
<parameter name="mail.smtp.user">admin@abc.com</parameter>
<parameter name="mail.smtp.password">XXXXX</parameter>
<parameter name="mail.smtp.from">Admin</parameter>
</transportSender>
Proxy configuration
To get a mail content in HTML format, we need to add HTML message formatter in axis2.xml
<messageFormatter contentType="text/html" class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
SendErrMailSequence configuration
If any error occurs in a message mediation flow, Administrator has to send mail to manager.
Axis configuration
To send mails, we use mail transport. Enable the 'MailTransportSender' to send emails in specific scenarios.
@axis2.xml;
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.host">smtp.gmail.com</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
<parameter name="mail.smtp.user">admin@abc.com</parameter>
<parameter name="mail.smtp.password">XXXXX</parameter>
<parameter name="mail.smtp.from">Admin</parameter>
</transportSender>
Proxy configuration
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FileProxy"
transports="https,http,vfs"
statistics="disable"
trace="disable"
startOnLoad="true">
<target faultSequence="sendErrMailSequence">
<inSequence>
.................
</inSEquence>
</proxy>
name="FileProxy"
transports="https,http,vfs"
statistics="disable"
trace="disable"
startOnLoad="true">
<target faultSequence="sendErrMailSequence">
<inSequence>
.................
</inSEquence>
</proxy>
To get a mail content in HTML format, we need to add HTML message formatter in axis2.xml
<messageFormatter contentType="text/html" class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
SendErrMailSequence configuration
<sequence xmlns="http://ws.apache.org/ns/synapse" name="sendErrMailSequence">
<property name="messageType" value="text/html" scope="axis2"/>
<property name="ContentType" value="text/html" scope="axis2"/>
<property name="Subject" value=" Error occured" scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ErrorMessage xmlns=""> Please check endpoint errors</ErrorMessage>
</soapenv:Body>
</soapenv:Envelope>
</format>
</payloadFactory>
<send>
<endpoint name="MailEpr">
<address uri="mailto:manager@abc.com"/>
</endpoint>
</send>
</sequence>
<property name="messageType" value="text/html" scope="axis2"/>
<property name="ContentType" value="text/html" scope="axis2"/>
<property name="Subject" value=" Error occured" scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ErrorMessage xmlns=""> Please check endpoint errors</ErrorMessage>
</soapenv:Body>
</soapenv:Envelope>
</format>
</payloadFactory>
<send>
<endpoint name="MailEpr">
<address uri="mailto:manager@abc.com"/>
</endpoint>
</send>
</sequence>