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>
Hi,
ReplyDeleteIam working in wso2 emm2.0.1. To add the user i'd to send the mail But it is showing axis fault error. I've done the changes mentioned above eventhough i am getting the same error,
org.apache.axis2.AxisFault: Error generating mail message
at org.apache.axis2.transport.base.AbstractTransportSender.handleException(AbstractTransportSender.java:226)
at org.apache.axis2.transport.mail.MailTransportSender.sendMessage(MailTransportSender.java:184)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.axis2.client.ServiceClient.fireAndForget(ServiceClient.java:511)
at org.apache.axis2.client.ServiceClient.fireAndForget(ServiceClient.java:488)
at org.wso2.carbon.email.sender.core.service.EmailSenderServiceImpl$EmailSender.run(EmailSenderServiceImpl.java:117)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Please help me to solve the issue.