user1145598
user1145598

Reputation: 41

Mule ESB: Retrieving email messages from Gmail using IMAP connector

I am new to Mule and im trying to create a Mule configuration that pulls sent emails from a GMail account via imap and pushes them to a php script that processes and stores them in a custom CRM that i've built. For starters, i'm just trying to get the inbox emails dumped into a text files and i plan to work from there.

As new messages are received by the mailbox, Mule should pick up the new messages and process them automatically.

The Mule config looks like this so far:

<imaps:connector name="IMAP" mailboxFolder="INBOX" validateConnections="false" doc:name="IMAP" />
<flow name="flows1Flow1" doc:name="flows1Flow1">
    <imaps:inbound-endpoint host="imap.gmail.com" port="993" user="[[username]]%40gmail.com" password="[[password]]" connector-ref="IMAP" doc:name="IMAP"/>
   <file:outbound-endpoint path="D:\mailflow" outputPattern="msg_#[function:date].txt" doc:name="File"/>
</flow>

The program runs and gets to this point:

    INFO  2012-01-12 13:51:06,606 [main] org.mule.DefaultMuleContext: 
    **********************************************************************
    * Application: mailflow                                     *
    * OS encoding: Cp1252, Mule encoding: UTF-8                          *
    *                                                                    *
    * Agents Running:                                                    *
    *   JMX Agent                                                        *
    **********************************************************************
    INFO  2012-01-12 13:51:06,606 [main] org.mule.module.launcher.DeploymentService: 
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    + Started app 'mailflow'                          +
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

And then just sits there indefinitely, doing nothing?!

There is documentation suggesting that because i'm using IMAPS i need to add a TLS client and TLS key store to the imaps connector. I'm not sure what these are or how to use them though and the documentation is highly specialized and hard to understand. I'm also not sure that that's what the problem is in the first place as the app doesn't crash at any point.

Has anyone had success creating an imap flow with GMail? Please Help?!

Upvotes: 4

Views: 4216

Answers (5)

SDE
SDE

Reputation: 85

Settings for the IMAP

Use the app password https://security.google.com/settings/security/apppasswords and finally use the correct path for the mail to be saved.

Upvotes: 0

Rinkesh
Rinkesh

Reputation: 45

just put in a * and you wont see the error and will still work fine.

    <imaps:tls-client path="*" storePassword="*"/>
    <imaps:tls-trust-store path="*" storePassword="*"/>

Upvotes: 1

V&#237;ctor Romero
V&#237;ctor Romero

Reputation: 5115

Only non-deleted and unread messages are dispatched as messages (RetrieveMessageReceiver.java:148 and 149)

if (!messages[i].getFlags().contains(Flags.Flag.DELETED)
     && !messages[i].getFlags().contains(Flags.Flag.SEEN))

If the folder is big, it will take some time (potentially even hours) to get to the point to process unread messages.

Upvotes: 0

Mubashar Ali
Mubashar Ali

Reputation: 3

You have to change imap:connector and imap:inbound-endpoint to imaps:connector and imaps:inbound-endpoint.

It is working fine for me. I have the same issued and now it is fixed with this little change.

Upvotes: 0

German
German

Reputation: 11

Just create the connector like this:

<imaps:connector name="IMAP">
   <imaps:tls-client/>
   <imaps:tls-trust-store/>
</imaps:connector>

And that should do the trick. Also, I'd remove the "@gmail" from the user's definition, since it's not necessary.

Bye!

German

Upvotes: 1

Related Questions