Mule SMTP Connector
This tutorial explains about the Mule SMTP connector configuration. This can be used to send emails.
Pre-requisites:
- Anypoint Studio 5.1.0
- Any email smtp connection details like yahoo
Mule Flow:
Set message as payload (i.e. Test Message). This will be the email message.
SMTP Connector Configuration:
Source code:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
xmlns:http="http://www.mulesoft.org/schema/mule/http"xmlns:smtps="http://www.mulesoft.org/schema/mule/smtps"
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" version="EE-3.6.1"
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/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/smtps http://www.mulesoft.org/schema/mule/smtps/current/mule-smtps.xsd">
<http:listener-config name="HTTP_Listener_Configuration"
host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<flow name="yahooemailFlow">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/" doc:name="HTTP" />
<set-payload value="#['Test Message ']" doc:name="Set Payload" />
<smtps:outbound-endpoint host="${smtp_host_ip}"
responseTimeout="10000" doc:name="SMTP" from="fromemail@yahoo.com"
mimeType="text/html" password="password" subject="subject"
to="toemail@yahoo.com" user="fromemail%40yahoo.com" />
<logger message="Mail Sent #[payload]" level="INFO" doc:name="Logger" />
</flow>
</mule>
|