How to use smtp endpoint

8
How to use SMTP endpoint 16-05-2015

Transcript of How to use smtp endpoint

Page 1: How to use smtp endpoint

How to use SMTP endpoint

16-05-2015

Page 2: How to use smtp endpoint

Abstract

• The main motto of this PPT is How to use SMTP endpoint in our applications.

Page 3: How to use smtp endpoint

Introduction• The SMTP transport can be used for sending messages

over SMTP using thejavax.mail API. The implementation supports CC/BCC/ReplyTo addresses, attachments and custom Header properties. It also provides support forjavax.mail.Message transformation. The SMTPS connector enables SMTP over SSL using the javax.mail APIs. It supports all the elements and attributes of the SMTP transport, plus some required properties for setting up the client key store and the trust store for the SSL connection.

Page 4: How to use smtp endpoint

Example

Page 5: How to use smtp endpoint

.mflow• <?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="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.4.0" 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">• <smtp:gmail-connector name="Gmail" validateConnections="true" doc:name="Gmail"/>• <flow name="SMTPFlow1" doc:name="SMTPFlow1">• <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8087" path="smtp"

doc:name="HTTP"/>• <logger message="--Entered into the flow" level="INFO" doc:name="Logger"/>• <set-payload value="Hai Friend" doc:name="Set Payload"/>• <smtp:outbound-endpoint host="smtp.gmail.com" port="587" user=“****%40gmail.com" password=“****"

to=“****@gmail.com" from=“****@gmail.com" subject="Hai" responseTimeout="10000" connector-ref="Gmail" doc:name="SMTP"/>

• </flow>• </mule>

Page 6: How to use smtp endpoint

• Output:• Email will come to your inbox

Page 7: How to use smtp endpoint

• Flow of execution:1. URL to trigger the service from browserhttp://localhost:8087/smtp 2. Email will come to to-email address with the payload in set-payload component as body and subject in the SMTP component as mail subject