POP3 Connector in Mule | Receive Mails in Mule
POP3 (Post Office Protocol 3) is the most recent version of a standard protocol for receiving e-mail. POP3 is a client/server protocol in which e-mail is received and held for you by your Internet server.
flow of pop3 connector :
POP3 connector configuration :
before deploying the project on server we need to enable some settings in our gmail :
First of all turn on less secure app access in your gmail account by link :
https://myaccount.google.com/lesssecureapps
then go to critical security alert mail sent by google and choose option Yes it was me
Enable POP settings in your gmail.Here are the steps :
On your computer, open Gmail.
In the top right, click Settings .
Click Settings.
Click the Forwarding and POP/IMAP tab.
In the "POP download" section, select Enable POP for all mail or Enable POP for mail that arrives from now on.
At the bottom of the page, click Save Changes.
now all set.once your project is deployed.send a mail from your email to your or to anyone.
body of the mail will appear in logger output.
logger output :
XML project code :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:pop3="http://www.mulesoft.org/schema/mule/pop3" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/pop3 http://www.mulesoft.org/schema/mule/pop3/current/mule-pop3.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" basePath="/api" doc:name="HTTP Listener Configuration"/>
<pop3:connector name="POP3" checkFrequency="30000" validateConnections="true" doc:name="POP3">
</pop3:connector>
<flow name="test_pop3Flow">
<pop3:inbound-endpoint host="pop.gmail.com" port="995" user="******@gmail.com" password="*********" connector-ref="POP3" responseTimeout="1000" doc:name="POP3">
<property key="mail.pop3.ssl.enable" value="true"/>
</pop3:inbound-endpoint>
<object-to-string-transformer doc:name="Object to String"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>