0
votes

I am trying a simple Mule 3.3.0 configuration which will download every email and pass it on to my custom processor class. Once the email is retrieved it should be deleted from the gmail inbox. But that doesn't seem to be working. Below is my mule-config.xml





<spring:beans>
    <spring:import resource="classpath:spring/applicationContextServices-core.xml"/>
    <spring:import resource="classpath:spring/applicationContextServices-configuration.xml"/>
    <spring:bean id="emailSender" name="emailSender" class="com.test.EmailSender"/>
    <spring:bean id="retrieveEmailProcessor" name="retrieveEmailProcessor" class="com.test.RetrieveEmailProcessor"/>
</spring:beans>


<jms:activemq-connector name="Active_MQ" specification="1.1" username="[username]" password="[password]" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ">
    <reconnect/>
</jms:activemq-connector>

<pop3s:connector name="pop3Connector" checkFrequency="45600" deleteReadMessages="true"/>

<flow name="1_SendMessageToOwner" doc:name="1_SendMessageToOwner" doc:description="This is to confirm that your email was received successfully">
    <jms:inbound-endpoint topic="PoolMessage" connector-ref="Active_MQ" doc:name="JMS"/>
    <component doc:name="Build Email Message">
        <spring-object bean="emailSender"/>
    </component>
    <smtps:outbound-endpoint host="smtp.gmail.com" port="465" user="[username]%40gmail.com" password="[password]" from="[username]@gmail.com" responseTimeout="50000" doc:name="SMTP"/>
</flow>

<flow name="2_ReceiveConfirmation" doc:name="2_ReceiveConfirmation" doc:description="Retrieving Email">
    <pop3s:inbound-endpoint connector-ref="pop3Connector" host="pop.gmail.com" port="995" user="[username]%40gmail.com" password="[password]" responseTimeout="10000" doc:name="Pop3"/>
    <component doc:name="Process Transaction - Confirmation Message" doc:description="Recieve confirmation from member.">
        <spring-object bean="retrieveEmailProcessor"/>
    </component>
</flow>

</mule>

and the RetrieveEmailProcessor class

package com.test;

import java.util.Map;

import org.mule.api.MuleEventContext; import org.mule.api.lifecycle.Callable;

public class RetrieveEmailProcessor implements Callable {

public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("########## Entering RetrieveEmailProcessor.OnCall ##########"); Map dataMapMessage = (Map)eventContext.getMessage().getPayload(); String subject = (String)dataMapMessage.get("subject"); String toAddressList = (String)dataMapMessage.get("toAddressList"); String fromAddress = (String)dataMapMessage.get("fromAddress"); eventContext.getMessage().setOutboundProperty( "toAddresses", toAddressList); eventContext.getMessage().setOutboundProperty( "subject", subject); eventContext.getMessage().setOutboundProperty( "replyToAddresses", fromAddress); System.out.println("########## Exiting RetrieveEmailProcessor.OnCall ##########"); return dataMapMessage.get("mailBody"); }

}

Is there anything obvious that I am missing? Thanks in advance

1

1 Answers

1
votes

Your Mule configuration is fine.

You need to check your Gmail's configuration:
Settings -> Forwarding and POP/IMAP -> In POP Download: --> 2. When messages are accessed with POP

There you need to select "delete Gmail's copy" if you want your messages deleted or archived once they're read by the POP connector.