Mule ESB: Receive emails from Gmail using an IMAP connector

I am new to Mule and im trying to create a Mule configuration that sends sent emails from a GMail account via imap and pushes them to a PHP script that processes and saves them in a custom CRM that I created. To get started, I'm just trying to get inboxes of incoming messages uploaded to text files, and I plan to work from there.

When new messages are received by the mailbox, Mule should automatically receive new messages and process them.

The Mule configuration looks like this:

<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 starts 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 he just sits there endlessly, doing nothing ?!

There is documentation suggesting that since I use IMAPS, I need to add a TLS client and a TLS keystore to the imaps connector. I'm not sure what it is and how to use them, and the documentation is highly specialized and difficult to understand. I'm also not sure if the problem is that the application is not crashing at any time.

Has anyone managed to create an imap stream with GMail? Please, help?!

+4
source share
5 answers

Just create a connector as follows:

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

And that should do the trick. Also, I would remove "@gmail" from the user definition, since it is not needed.

Bye!

Deutsch

+1
source

just enter * and you will not see an error and will still work fine.

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

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

It works great for me. I got the same and now it is fixed with this small change.

0
source

Only non-deleted and unread messages are sent 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 large, it will take some time (possibly even hours) to receive unread messages.

0
source

Settings for IMAP

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

0
source

Source: https://habr.com/ru/post/1390645/


All Articles