Imagine a scenario you need to receive emails to WSO2 ESB where you are using the mail transport.
HOW TO:
Following steps will guide you to get your scenario up and running.
- Download a distribution of the WSO2 ESB [1].
ie. wso2esb-4.8.1.zip - Extract the zip file. The folder created (wso2esb-4.8.1) will be referred as ESB_HOME.
- Uncomment the mail TransportSender and TransportReceiver from axis2.xml ie. ESB_HOME/conf/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">synapse.demo.0</parameter> <parameter name="mail.smtp.password">mailpassword</parameter> <parameter name="mail.smtp.from">synapse.demo.0@gmail.com</parameter> </transportSender>
<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener"></transportReceiver>
- Go to the ESB_HOME/bin and run the script which starts wso2server.
eg. wso2server.bat for windows environments
wso2server.sh for linux environments - Then the server will be started. You can access the management console using the following URL [2].
- Log into the Mangement Console using following credentials.
username: admin
password: admin - If your using imap create a proxy service using the following proxy configuration.
<definitions xmlns="http://ws.apache.org/ns/synapse"> <proxy xmlns="http://ws.apache.org/ns/synapse" name="MailTransportProtocolIMAP" transports="mailto" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <log level="custom"> <property name="Date" expression="$trp:Date"/> <property name="Subject" expression="$trp:Subject"/> <property name="Content-Type" expression="$trp:Content-Type"/> <property name="From" expression="$trp:From"/> </log> <drop/> </inSequence> <outSequence> <send/> </outSequence> </target> <parameter name="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter> <parameter name="mail.imap.starttls.enable">false</parameter> <parameter name="transport.mail.ContentType">text/plain</parameter> <parameter name="mail.imap.host">imap.gmail.com</parameter> <parameter name="transport.mail.Address">test.automation.dummy@gmail.com</parameter> <parameter name="mail.imap.user">test.automation.dummy</parameter> <parameter name="mail.imap.socketFactory.port">993</parameter> <parameter name="transport.PollInterval">2</parameter> <parameter name="mail.imap.port">993</parameter> <parameter name="mail.imap.ssl.enable">false</parameter> <parameter name="mail.imap.fetchsize">2</parameter> <parameter name="mail.imap.socketFactory.fallback">false</parameter> <parameter name="transport.mail.Protocol">imap</parameter> <parameter name="mail.imap.password">automation.test</parameter> <description/> </proxy> </definitions>
- Or if you're using pop3 create a proxy service using the following proxy configuration.
<definitions xmlns="http://ws.apache.org/ns/synapse"> <proxy xmlns="http://ws.apache.org/ns/synapse" name="MailTranportAddress" transports="mailto" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <log level="custom"> <property name="Date" expression="$trp:Date"/> <property name="Subject" expression="$trp:Subject"/> <property name="Content-Type" expression="$trp:Content-Type"/> <property name="From" expression="$trp:From"/> </log> <drop/> </inSequence> <outSequence> <send/> </outSequence> </target> <parameter name="mail.pop3.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter> <parameter name="transport.mail.ContentType">text/plain</parameter> <parameter name="mail.pop3.host">pop.gmail.com</parameter> <parameter name="transport.mail.Address">test.automation.dummy@gmail.com</parameter> <parameter name="mail.pop3.user">test.automation.dummy</parameter> <parameter name="mail.pop3.socketFactory.port">995</parameter> <parameter name="transport.PollInterval">1</parameter> <parameter name="mail.pop3.port">995</parameter> <parameter name="mail.pop3.fetchsize">1</parameter> <parameter name="mail.pop3.socketFactory.fallback">false</parameter> <parameter name="transport.mail.Protocol">pop3</parameter> <parameter name="mail.pop3.password">automation.test</parameter> <description/> </proxy> </definitions>
- Send email to test.automation.dummy@gmail.com.
- Now you can see the email receiving to ESB by looking at the log.
[1] – http://wso2.org/downloads/esb
No comments:
Post a Comment