1
votes

I just installed my brand new WSO2 ESB 4.9.0. This is the latest version which I downloaded yesterday.

I am trying to get my ESB to receive e-mail from a server. I have tried POP3 and IMAP. I have been using several references to help me(Since I am a new member, my reputation does not yet allow me to post proper links to all my references):

  • stackoverflow.com/questions/27376833/wso2-mailto-transport-emptied-my-inbox
  • javamail.java.net/nonav/docs/api/com/sun/mail/pop3/package-summary.html
  • javamail.java.net/nonav/docs/api/com/sun/mail/imap/package-summary.html
  • sparkletechthoughts.blogspot.fr/2013/10/how-to-receive-emails-to-wso2-esb.html
  • charithaka.blogspot.com/2012/11/how-to-enable-mail-transport-for-wso2.html
  • irhamiqbal.wordpress.com/how-to-receive-email-using-wso2-esb/
  • jayalalk.blogspot.com/2014/06/wso2-esb-mail-sending-with-html-complex.html

And of course the official documentation:

All of my reading leads me to believe that I have everything set up properly (or if not properly, good enough to get some error messages to troubleshoot).

I did restart the WSO2 ESB and the following message shows up in the console log:

TID[-1234] [ESB] [2016-08-02 21:45:37,237] INFO {org.apache.axis2.transport.mail.MailTransportListener} - MAILTO listener started 

I get no other indication in the logs one way or another.

I edited (and double checked) my $CARBON_HOME/repository/conf/axis2/axis2.xml, and I'm pretty sure I have the mail transport enabled properly:

<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener">
    <!-- configure any optional POP3/IMAP properties
    check com.sun.mail.pop3 and com.sun.mail.imap package documentation for more details-->
</transportReceiver>
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
    <parameter name="mail.smtp.host">my.smtp.server</parameter>
    <parameter name="mail.smtp.port">587</parameter>
    <parameter name="mail.smtp.starttls.enable">false</parameter>
    <parameter name="mail.smtp.auth">true</parameter>
    <parameter name="mail.smtp.user">[email protected]</parameter>
    <parameter name="mail.smtp.password">password</parameter>
    <parameter name="mail.smtp.from">[email protected]</parameter>
</transportSender>

And, finally, I have my Proxy Service setup (in its current iteration, anyway):

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="JasperEmailPOP3"
       transports="mailto"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="senderAddress"
                   expression="get-property('transport', 'From')"
                   scope="default"
                   type="STRING"/>
         <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.PollInterval">5</parameter>
   <parameter name="mail.pop3.host">my.pop3.email</parameter>
   <parameter name="mail.pop3.user">[email protected]</parameter>
   <parameter name="transport.mail.Protocol">pop3</parameter>
   <parameter name="mail.pop3.socketFactory.port">995</parameter>
   <parameter name="transport.mail.Address">[email protected]</parameter>
   <parameter name="mail.pop3.password">password</parameter>
   <parameter name="mail.pop3.port">995</parameter>
   <parameter name="mail.pop3.socketFactory.fallback">false</parameter>
   <description/>
</proxy>

With all of this, my question is: is there something else I am missing to get the ESB to at least attempt to retrieve e-mail? What bothers me is I am not getting any error messages to troubleshoot (such as my mail not being in plain test).

1
Were you successful in solving your problem? I want to extract attached files from the incoming mail and put them on my local filesystem. I could not find much samples out there. Have you consider this scenario too?user2120188
Hi, I'm interested too: I can't find samples of reading email attachments. Moreover, the attachments will be signed with a SMIME certificate. I guess once I can retrieve attachments I'll have to deal with certificate through a custom Java mediator.Julien Gecko

1 Answers

1
votes

I tried the same scenario with a Gmail account and it works fine for me, seems like some mis-configuration in your POP server. You need to add following property as well.

<parameter name="transport.mail.ContentType">text/plain</parameter>

See the full proxy configs below.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="JasperEmailPOP3"
       transports="mailto"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="senderAddress"
                   expression="get-property('transport', 'From')"
                   scope="default"
                   type="STRING"/>
         <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.PollInterval">5</parameter>
   <parameter name="mail.pop3.host">pop.gmail.com</parameter>
   <parameter name="mail.pop3.user">ycwso2test</parameter>
   <parameter name="transport.mail.Protocol">pop3</parameter>
   <parameter name="mail.pop3.socketFactory.port">995</parameter>
   <parameter name="transport.mail.Address">[email protected]</parameter>
   <parameter name="mail.pop3.password">wso2qa123</parameter>
   <parameter name="mail.pop3.port">995</parameter>
   <parameter name="mail.pop3.socketFactory.fallback">false</parameter>
   <parameter name="transport.mail.ContentType">text/plain</parameter>
   <description/>
</proxy>

Also if you need to further debug this you can enable DEBUG logs. To do this add the following line to repository/conf/log4j.properties and restart.

log4j.logger.org.apache.axis2.transport.mail.MailTransportListener=DEBUG