Send Email in Mule 4 | SMTP in Mule 4
Email sending functionality in mule 4 is accomplished by send under email component.
Flow:
Send component settings:
Connector configuration:
Advance settings:
In advance tab:
Put a property as:
Key: mail.smtp.starttls.enable
Value: true
Method: GET
One important thing is you might get critical security alert mail from google for sign in by some different device. for this you have to turn on less secure app access by link :
https://myaccount.google.com/lesssecureapps
https://myaccount.google.com/lesssecureapps
Now it is all set !!!....Hit the URL and you will get the mail in your inbox.
XML Project code:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="00e4ba9f-b70b-4fec-911a-869f91a67a0f" >
<http:listener-connection host="0.0.0.0" port="8085" />
</http:listener-config>
<email:smtp-config name="Email_SMTP" doc:name="Email SMTP" doc:id="50713db3-050f-4a67-b2d9-142b2b6ac8d3" >
<email:smtp-connection host="smtp.gmail.com" port="587" user="himanshu452001@gmail.com" password="" >
<email:properties >
<email:property key="mail.smtp.starttls.enable" value="true" />
</email:properties>
</email:smtp-connection>
</email:smtp-config>
<email:imap-config name="Email_IMAP" doc:name="Email IMAP" doc:id="25b8bba2-5949-4d9b-92f9-852b36abf161" >
<email:imap-connection host="smtp.gmail.com" port="587" user="himanshu452001@gmail.com" password="" >
<email:properties >
<email:property key="mail.smtp.starttls.enable" value="true" />
</email:properties>
</email:imap-connection>
</email:imap-config>
<flow name="test_emailFlow" doc:id="3ce7ecb5-d649-4774-b1cb-b297ec882519" >
<http:listener doc:name="Listener" doc:id="f5150eac-056b-4655-901c-c2ec8022b8b5" config-ref="HTTP_Listener_config" path="/send"/>
<email:send doc:name="Send" doc:id="c73ad1de-d0dd-4be7-9373-cfe6d852c896" config-ref="Email_SMTP" fromAddress="himanshu452001@gmail.com" subject="hello">
<email:to-addresses >
<email:to-address value="himanshu452001@gmail.com" />
</email:to-addresses>
<email:body contentType="text/plain">
</email:body>
</email:send>
</flow>
</mule>
No comments:
Post a Comment