Mule ESB: Retrieving email messages from Gmail using IMAP connector

旧街凉风 提交于 2019-12-10 15:52:25

问题


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?!


回答1:


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




回答2:


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="*"/>



回答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.




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/8836530/mule-esb-retrieving-email-messages-from-gmail-using-imap-connector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!