2. SMTP
O Simple Mail Transfer Protocol (SMTP) is an
Internet standard for electronic mail (email)
transmission
O SMTP by default uses TCP port 25. The protocol
for mail submission is the same, but uses port 587.
O SMTP connections secured bySSL, known
as SMTPS, default to port 465
O Most e-mail systems that send mail over
the Internet use SMTP to send messages from one
server to another; the messages can then be
retrieved with an e-mail client using
either POP or IMAP. In addition, SMTP is generally
used to send messages from a mail client to a mail
server.
3. SMTP Transport
O Introduction
O The SMTP transport can be used for sending messages over SMTP
using the javax.mail API. The implementation supports
CC/BCC/ReplyTo addresses, attachments and custom Header
properties. It also provides support
for javax.mail.Messagetransformation. 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.
O TLS/SSL connections are made on behalf of an entity, which can be
anonymous or identified by a certificate. The key store provides the
certificates and associated private keys necessary for identifying
the entity making the connection. Additionally, connections are
made to trusted systems. The public certificates of trusted systems
are stored in a trust store, which is used to verify that the
connection made to a remote system matches the expected identity.
5. Flow Description
O Http component invokes the sample flow.
O Variable is used to set content of
attachment.
O Attachment is the file to be added to
email.
O Anything in Set Payload gets added to
message body.
O SMTP component is to configure and
send mail.
6. XML
O <?xml version="1.0" encoding="UTF-8"?>
O <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"
O xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0"
O xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
O xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
O http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
O http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
O http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd">
O <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"
basePath="sendmail"/>
O <smtp:gmail-connector name="Gmail" validateConnections="true" doc:name="Gmail"/>
O <flow name="email_sampleFlow">
O <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
O <set-variable variableName="attachmentString" value="This is an sample content of Attachment file........." doc:name="Variable"/>
O <set-attachment attachmentName="AttachmentFile.txt" value="#[flowVars.attachmentString]" contentType="text/plain"
doc:name="Attachment"/>
O <set-payload value="Hello --- This is Message Body" doc:name="Set Payload"/>
O <smtp:outbound-endpoint host="smtp.gmail.com" port="587" user=“sender%40gmail.com" password=“*******" connector-ref="Gmail"
to=“receiver@gmail.com" subject="Message Subject" responseTimeout="10000" doc:name="SMTP"/>
O </flow>
O </mule>
8. Assumption
O The above example is done using Mule
3.6
O Gmail is used to send and receive mail
O Attachment component is used to attach
file
O Flow is tested and works in Mule 3.5.2
O SMTP details
O Host: smtp.gmail.com
O Port: 587