This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata

Objective: Using the  MailTo transport with Proxy Services.

  • You will need access to an e-mail account.
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already done.
  • Enable the mail transport listener in the ESB axis2.xml. Simply uncomment the relevant transport receiver entry in the file and update parameters with values which relevant to email account which you are using.
  • Enable mail transport sender in the ESB axis2.xml. See MailTo transport for details.
  • Open [ESB_HOME]/repository/samples/synapse_sample_256.xml and update proxy service parameters appropriate to your email account 
  • Start the Synapse configuration numbered 256: -sn 256.
  • Send a plain/text e-mail (Make sure you switch to Plain text mode when you are composing the email) with the following body and any custom Subject from your mail account to the mail address [email protected].

    <m0:getQuote xmlns:m0="http://services.samples">
  • After a few seconds (for example 30 seconds), you should receive a POX response in your e-mail account with the stock quote reply.
<!-- Using the mail transport -->
<definitions xmlns="">
    <proxy name="StockQuoteProxy" transports="mailto">
        <parameter name="transport.mail.Address">[email protected]</parameter>
        <parameter name="transport.mail.Protocol">pop3</parameter>
        <parameter name="transport.PollInterval">5</parameter>
        <parameter name=""></parameter>
        <parameter name="mail.pop3.port">995</parameter>
        <parameter name="mail.pop3.user">synapse.demo.1</parameter>
        <parameter name="mail.pop3.password">mailpassword1</parameter>
        <parameter name="mail.pop3.socketFactory.class"></parameter>
        <parameter name="mail.pop3.socketFactory.fallback">false</parameter>
        <parameter name="mail.pop3.socketFactory.port">995</parameter>
        <parameter name="transport.mail.ContentType">application/xml</parameter>
                <property name="senderAddress" expression="get-property('transport', 'From')"/>
                <log level="full">
                    <property name="Sender Address" expression="get-property('senderAddress')"/>
                        <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                <property name="Subject" value="Custom Subject for Response" scope="transport"/>
                <header name="To" expression="fn:concat('mailto:', get-property('senderAddress'))"/>
                <log level="full">
                    <property name="message" value="Response message"/>
                    <property name="Sender Address" expression="get-property('senderAddress')"/>
        <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>


In this sample, we used the transport.mail.ContentType property to make sure that the transport parses the request message as POX. If you remove this property, you may still be able to send requests using a standard mail client if instead of writing the XML in the body of the message, you add it as an attachment. In that case, you should use XML as a suffix for the attachment and format the request as a SOAP 1.1 message. Indeed, for a file with suffix XML the mail client will most likely use text/XML as the content type, exactly as required for SOAP 1.1. Sending a POX message using this approach will be a lot trickier, because most standard mail clients do not allow the user to explicitly set the content type.

  • No labels