Search code examples
javaemailmulejakarta-mail

How to read mail and insert into database using Mule?


I have to create an application in Mule which will read the mail from a store and save it's details in a database. I know how to insert the data into the database but I am unable to find any solution about the mail. How do I read the mail and parse it in Mule?


Solution

  • I think the answers are correct, however rather than hand rolling your own solution you might be better off using the IMAP connector

    A sample could be like the below

    <flow name="incoming-orders">
            <imaps:inbound-endpoint user="${mail.user}" password="${mail.password}" host="${mail.host}" 
                         port="${mail.port}"/>
         <logger message="#[payload]" level="INFO" doc:name="Logger" />
         </flow>