SlideShare a Scribd company logo
Send email attachment using
SMTP in Mule ESB
Presented by : Ravi Mishra
What is Mule ESB ?
 Mule ESB is a lightweight Java-based
enterprise service bus (ESB) and
integration platform that allows
developers to connect applications
together quickly and easily, enabling
them to exchange data. Mule ESB
enables easy integration of existing
systems, regardless of the different
technologies that the applications use,
including JMS, Web Services, JDBC,
HTTP, and more.
 This example shows how we can send email
attachment using SMTP connector to self or
another email. We simply put a file in a source
directory and Mule will read the file from the
source directory. Using Mule ESB it’s very easy
to read the file from a location. If we had to read
the file using manual coding then we had to write
many lines of code. But using Mule ESB we just
simply put a file in a directory and let the Mule
know the file path and Mule does the rest of the
thing. You can put any kind of file to the source
for reading. The file that we put into a source
directory will be an attachment to the intended
recipient’s mail address. So finally when we will
see the file as an attachment in the mailbox.
What is Attachment
transformer ?
 Attachment transformer lets us attach
a file or document which will be sent to
the email address.
What is SMTP connector ?
 The SMTP endpoint allows Mule
messages to be sent as email or email
attachments with the Simple Mail
Transfer Protocol (SMTP) using Java
mail API.
Prerequisites
 Mule Studio 3.5.1
JDK 1.6
Maven 3
Mule Runtime 3.5.0 CE
Knowledge of XML
 Open Mule Studio and create a mule project.
Go to File->New->Mule Project. Now enter
the Project Name, selectRuntime – Mule
Server, check the check box for Use Maven.
Now enter the following information
 Group Id: your Mail(ex. gmail.com)
Artifact Id: project name – file-
attachment(automatically populated when
project name is getting typed)
V
 Click Next and verify project Location and
JRE/JDK are set correctly. Click
Finishersion: Mule studio generates default
 Now drag and drop the elements from right
side of the Mule studio as shown below in
the picture.
Browse and select the path from where a file will be read for an attachment.
Logger component properties
 File to String transformer properties
 File-to-Strong transformer just transforms
the file object to human readable string
format. We will not set any property for this
element
Attachment transformer properties
 Using attachment transformer we can set
payload from previous flow as an
attachment. We have to select Content
Type, operation as Set Attachment, Name,
Value
 SMTP connector properties
For SMTP connector we have to input email host, user name, password, port
under Basic Settings and To Address, From Address, Subject under Email
Information.
 The whole XML file of entire flow
 <?xml version="1.0" encoding="UTF-8"?>

 <mule xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
 xmlns:file="http://www.mulesoft.org/schema/mule/file" 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="CE-3.5.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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
 http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd">
 <flow name="file-attachmentFlow1" doc:name="file-attachmentFlow1">
 <file:inbound-endpoint path="D:AnypointWorkspacesource"
 responseTimeout="10000" doc:name="File" />
 <logger message="#[payload]" level="INFO" doc:name="Logger" />
 <file:file-to-string-transformer
 doc:name="File to String" />
 <logger message="#[payload]" level="INFO" doc:name="Logger" />
 <set-attachment attachmentName="attachment" value="#[payload]"
 contentType="text/plain" doc:name="Attachment" />
 <logger message="#[payload]" level="INFO" doc:name="Logger" />
 <smtp:outbound-endpoint host="mail.domain.com"
 user="emailAddress@domain.com" password="password" to="emailAddress@domain.com"
 from="emailAddress@domain.com" subject="Test Email" responseTimeout="10000"
 doc:name="SMTP" />
 <logger message="#[payload]" level="INFO" doc:name="Logger" />
 </flow>
 </mule>
 Now create a text file called file-
attachment.txt and put it under selected path,
i.e., as per the above XML the file path
is D:AnypointWorkspacesource.
 Do right-click on file-attachment.xml and
click on Run As -> Mule Application with
Maven. Once the application up and running
you will get the console output and email
attachment in your mailbox where you have
sent the email.
 Output in console
 INFO 2015-03-05 09:25:46,372 [[file-
attachment].connector.file.mule.default.receiver.01]
org.mule.transport.file.FileMessageReceiver: Lock obtained on file:
D:AnypointWorkspacesourcefile-attachment.txt
 INFO 2015-03-05 09:25:46,404 [[file-attachment].file-
attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor:
org.mule.transport.file.ReceiverFileInputStream@6a150e
 INFO 2015-03-05 09:25:46,406 [[file-attachment].file-
attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor:
This is a file content
 INFO 2015-03-05 09:25:46,407 [[file-attachment].file-
attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor:
This is a file content
 INFO 2015-03-05 09:25:46,419 [[file-attachment].file-
attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor:
This is a file content
 INFO 2015-03-05 09:25:46,422 [[file-
attachment].connector.smtp.mule.default.dispatcher.01]
org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default
outbound transformer:
org.mule.transport.email.transformers.ObjectToMimeMessage
 INFO 2015-03-05 09:25:46,428 [[file-
attachment].connector.smtp.mule.default.dispatcher.01]
org.mule.lifecycle.AbstractLifecycleManager: Initialising:
'connector.smtp.mule.default.dispatcher.1213248'. Object is:
SmtpMessageDispatcher
 Click on the attachment. You will see the
below output in the browser.

More Related Content

What's hot

How muleworks
How muleworksHow muleworks
How muleworks
Khadhar Koneti
 
Mule soa
Mule soaMule soa
Mule soa
D.Rajesh Kumar
 
Soap in mule
Soap in muleSoap in mule
Soap in mule
D.Rajesh Kumar
 
Vm component in mule demo
Vm component in mule demoVm component in mule demo
Vm component in mule demo
Sudha Ch
 
Mule enterprise service introduction
Mule enterprise service introductionMule enterprise service introduction
Mule enterprise service introduction
Son Nguyen
 
Mule soa
Mule soaMule soa
Mule soa
Son Nguyen
 
Mule esb mule message
Mule esb   mule messageMule esb   mule message
Mule esb mule message
sathyaraj Anand
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
Praneethchampion
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
Praneethchampion
 
Core concepts in mule
Core concepts in muleCore concepts in mule
Core concepts in mule
Sindhu VL
 
Design flows in mule
Design flows in muleDesign flows in mule
Design flows in mule
Sindhu VL
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
Praneethchampion
 
Mule velocity
Mule velocityMule velocity
Mule velocity
Praneethchampion
 
Connectors in mule
Connectors in muleConnectors in mule
Connectors in mule
Sindhu VL
 
Testing mule
Testing   muleTesting   mule
Testing mule
Sindhu VL
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Khasim Cise
 
Mule esb introduction
Mule esb introductionMule esb introduction
Mule esb introduction
Praneethchampion
 
Rabbit Mq in Mule
Rabbit Mq in MuleRabbit Mq in Mule
Rabbit Mq in Mule
Mohammed246
 

What's hot (18)

How muleworks
How muleworksHow muleworks
How muleworks
 
Mule soa
Mule soaMule soa
Mule soa
 
Soap in mule
Soap in muleSoap in mule
Soap in mule
 
Vm component in mule demo
Vm component in mule demoVm component in mule demo
Vm component in mule demo
 
Mule enterprise service introduction
Mule enterprise service introductionMule enterprise service introduction
Mule enterprise service introduction
 
Mule soa
Mule soaMule soa
Mule soa
 
Mule esb mule message
Mule esb   mule messageMule esb   mule message
Mule esb mule message
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
 
Core concepts in mule
Core concepts in muleCore concepts in mule
Core concepts in mule
 
Design flows in mule
Design flows in muleDesign flows in mule
Design flows in mule
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
 
Mule velocity
Mule velocityMule velocity
Mule velocity
 
Connectors in mule
Connectors in muleConnectors in mule
Connectors in mule
 
Testing mule
Testing   muleTesting   mule
Testing mule
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
 
Mule esb introduction
Mule esb introductionMule esb introduction
Mule esb introduction
 
Rabbit Mq in Mule
Rabbit Mq in MuleRabbit Mq in Mule
Rabbit Mq in Mule
 

Similar to Send email attachment using smtp in mule esb

Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
princeirfancivil
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
irfan1008
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
Phaniu
 
Email using mule
Email using muleEmail using mule
Email using mule
Manav Prasad
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
Anand kalla
 
Email configuration in mule esb
Email configuration in mule esbEmail configuration in mule esb
Email configuration in mule esb
Vamsi Krishna
 
Mule connectors-part 1
Mule connectors-part 1Mule connectors-part 1
Mule connectors-part 1
VirtusaPolaris
 
Mule connectors-session1
Mule connectors-session1Mule connectors-session1
Mule connectors-session1
Vishnukanth Rachineni
 
Adding dynamic file
Adding dynamic fileAdding dynamic file
Adding dynamic file
Son Nguyen
 
Mule esb
Mule esbMule esb
Mule esb
sathyaraj Anand
 
XML Tutor maXbox starter27
XML Tutor maXbox starter27XML Tutor maXbox starter27
XML Tutor maXbox starter27
Max Kleiner
 
Mule ESB
Mule ESBMule ESB
Mule ESB
Yura Nosenko
 
Mule ESB Components
Mule ESB Components Mule ESB Components
Mule ESB Components
pat_91
 
mulesoft
mulesoftmulesoft
mulesoft
Thota Kumar
 
File component in mule demo
File component in mule demoFile component in mule demo
File component in mule demo
Sudha Ch
 
Web services
Web servicesWeb services
Web services
Thota Kumar
 
Dynamic file attribute
Dynamic file attributeDynamic file attribute
Dynamic file attribute
Anirban Sen Chowdhary
 
File component
File component File component
File component
Sunil Komarapu
 
Mule File component
Mule File component Mule File component
Mule File component
AbdulImrankhan7
 
File component
File component File component
File component
F K
 

Similar to Send email attachment using smtp in mule esb (20)

Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Email using mule
Email using muleEmail using mule
Email using mule
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Email configuration in mule esb
Email configuration in mule esbEmail configuration in mule esb
Email configuration in mule esb
 
Mule connectors-part 1
Mule connectors-part 1Mule connectors-part 1
Mule connectors-part 1
 
Mule connectors-session1
Mule connectors-session1Mule connectors-session1
Mule connectors-session1
 
Adding dynamic file
Adding dynamic fileAdding dynamic file
Adding dynamic file
 
Mule esb
Mule esbMule esb
Mule esb
 
XML Tutor maXbox starter27
XML Tutor maXbox starter27XML Tutor maXbox starter27
XML Tutor maXbox starter27
 
Mule ESB
Mule ESBMule ESB
Mule ESB
 
Mule ESB Components
Mule ESB Components Mule ESB Components
Mule ESB Components
 
mulesoft
mulesoftmulesoft
mulesoft
 
File component in mule demo
File component in mule demoFile component in mule demo
File component in mule demo
 
Web services
Web servicesWeb services
Web services
 
Dynamic file attribute
Dynamic file attributeDynamic file attribute
Dynamic file attribute
 
File component
File component File component
File component
 
Mule File component
Mule File component Mule File component
Mule File component
 
File component
File component File component
File component
 

More from RaviShankar Mishra

Mulesoft meetup 29.06
Mulesoft meetup 29.06Mulesoft meetup 29.06
Mulesoft meetup 29.06
RaviShankar Mishra
 
Hyderbad meetup 19th jan
Hyderbad meetup 19th janHyderbad meetup 19th jan
Hyderbad meetup 19th jan
RaviShankar Mishra
 
Token Management using Stormpath inside Mule
Token Management using Stormpath inside MuleToken Management using Stormpath inside Mule
Token Management using Stormpath inside Mule
RaviShankar Mishra
 
Drools rule Concepts
Drools rule ConceptsDrools rule Concepts
Drools rule Concepts
RaviShankar Mishra
 
Data weave in Mule
Data weave in MuleData weave in Mule
Data weave in Mule
RaviShankar Mishra
 
Creating restful api using mule esb
Creating restful api using mule esbCreating restful api using mule esb
Creating restful api using mule esb
RaviShankar Mishra
 
Connecting to salesforce and using database in mule
Connecting to salesforce and using database in muleConnecting to salesforce and using database in mule
Connecting to salesforce and using database in mule
RaviShankar Mishra
 

More from RaviShankar Mishra (7)

Mulesoft meetup 29.06
Mulesoft meetup 29.06Mulesoft meetup 29.06
Mulesoft meetup 29.06
 
Hyderbad meetup 19th jan
Hyderbad meetup 19th janHyderbad meetup 19th jan
Hyderbad meetup 19th jan
 
Token Management using Stormpath inside Mule
Token Management using Stormpath inside MuleToken Management using Stormpath inside Mule
Token Management using Stormpath inside Mule
 
Drools rule Concepts
Drools rule ConceptsDrools rule Concepts
Drools rule Concepts
 
Data weave in Mule
Data weave in MuleData weave in Mule
Data weave in Mule
 
Creating restful api using mule esb
Creating restful api using mule esbCreating restful api using mule esb
Creating restful api using mule esb
 
Connecting to salesforce and using database in mule
Connecting to salesforce and using database in muleConnecting to salesforce and using database in mule
Connecting to salesforce and using database in mule
 

Recently uploaded

CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
PKavitha10
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
edwin408357
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
ycwu0509
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
mahaffeycheryld
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
PreethaV16
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 

Recently uploaded (20)

CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 

Send email attachment using smtp in mule esb

  • 1. Send email attachment using SMTP in Mule ESB Presented by : Ravi Mishra
  • 2. What is Mule ESB ?  Mule ESB is a lightweight Java-based enterprise service bus (ESB) and integration platform that allows developers to connect applications together quickly and easily, enabling them to exchange data. Mule ESB enables easy integration of existing systems, regardless of the different technologies that the applications use, including JMS, Web Services, JDBC, HTTP, and more.
  • 3.  This example shows how we can send email attachment using SMTP connector to self or another email. We simply put a file in a source directory and Mule will read the file from the source directory. Using Mule ESB it’s very easy to read the file from a location. If we had to read the file using manual coding then we had to write many lines of code. But using Mule ESB we just simply put a file in a directory and let the Mule know the file path and Mule does the rest of the thing. You can put any kind of file to the source for reading. The file that we put into a source directory will be an attachment to the intended recipient’s mail address. So finally when we will see the file as an attachment in the mailbox.
  • 4. What is Attachment transformer ?  Attachment transformer lets us attach a file or document which will be sent to the email address.
  • 5. What is SMTP connector ?  The SMTP endpoint allows Mule messages to be sent as email or email attachments with the Simple Mail Transfer Protocol (SMTP) using Java mail API.
  • 6. Prerequisites  Mule Studio 3.5.1 JDK 1.6 Maven 3 Mule Runtime 3.5.0 CE Knowledge of XML
  • 7.  Open Mule Studio and create a mule project. Go to File->New->Mule Project. Now enter the Project Name, selectRuntime – Mule Server, check the check box for Use Maven. Now enter the following information  Group Id: your Mail(ex. gmail.com) Artifact Id: project name – file- attachment(automatically populated when project name is getting typed) V  Click Next and verify project Location and JRE/JDK are set correctly. Click Finishersion: Mule studio generates default
  • 8.  Now drag and drop the elements from right side of the Mule studio as shown below in the picture.
  • 9.
  • 10. Browse and select the path from where a file will be read for an attachment. Logger component properties
  • 11.  File to String transformer properties  File-to-Strong transformer just transforms the file object to human readable string format. We will not set any property for this element Attachment transformer properties
  • 12.  Using attachment transformer we can set payload from previous flow as an attachment. We have to select Content Type, operation as Set Attachment, Name, Value
  • 13.  SMTP connector properties For SMTP connector we have to input email host, user name, password, port under Basic Settings and To Address, From Address, Subject under Email Information.
  • 14.  The whole XML file of entire flow  <?xml version="1.0" encoding="UTF-8"?>   <mule xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"  xmlns:file="http://www.mulesoft.org/schema/mule/file" 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="CE-3.5.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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd  http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd">  <flow name="file-attachmentFlow1" doc:name="file-attachmentFlow1">  <file:inbound-endpoint path="D:AnypointWorkspacesource"  responseTimeout="10000" doc:name="File" />  <logger message="#[payload]" level="INFO" doc:name="Logger" />  <file:file-to-string-transformer  doc:name="File to String" />  <logger message="#[payload]" level="INFO" doc:name="Logger" />  <set-attachment attachmentName="attachment" value="#[payload]"  contentType="text/plain" doc:name="Attachment" />  <logger message="#[payload]" level="INFO" doc:name="Logger" />  <smtp:outbound-endpoint host="mail.domain.com"  user="emailAddress@domain.com" password="password" to="emailAddress@domain.com"  from="emailAddress@domain.com" subject="Test Email" responseTimeout="10000"  doc:name="SMTP" />  <logger message="#[payload]" level="INFO" doc:name="Logger" />  </flow>  </mule>
  • 15.  Now create a text file called file- attachment.txt and put it under selected path, i.e., as per the above XML the file path is D:AnypointWorkspacesource.  Do right-click on file-attachment.xml and click on Run As -> Mule Application with Maven. Once the application up and running you will get the console output and email attachment in your mailbox where you have sent the email.
  • 16.  Output in console  INFO 2015-03-05 09:25:46,372 [[file- attachment].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: D:AnypointWorkspacesourcefile-attachment.txt  INFO 2015-03-05 09:25:46,404 [[file-attachment].file- attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: org.mule.transport.file.ReceiverFileInputStream@6a150e  INFO 2015-03-05 09:25:46,406 [[file-attachment].file- attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: This is a file content  INFO 2015-03-05 09:25:46,407 [[file-attachment].file- attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: This is a file content  INFO 2015-03-05 09:25:46,419 [[file-attachment].file- attachmentFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: This is a file content  INFO 2015-03-05 09:25:46,422 [[file- attachment].connector.smtp.mule.default.dispatcher.01] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.email.transformers.ObjectToMimeMessage  INFO 2015-03-05 09:25:46,428 [[file- attachment].connector.smtp.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.smtp.mule.default.dispatcher.1213248'. Object is: SmtpMessageDispatcher
  • 17.  Click on the attachment. You will see the below output in the browser.