SlideShare a Scribd company logo
1 of 17
Send email attachment using
SMTP in Mule ESB
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

Introduction to testing mule
Introduction to testing muleIntroduction to testing mule
Introduction to testing muleRamakrishna kapa
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interfacekrishananth
 
Concepts in mule
Concepts in muleConcepts in mule
Concepts in muleSindhu VL
 
Choice component in mule
Choice component in mule Choice component in mule
Choice component in mule Rajkattamuri
 
Mulesoft file connector
Mulesoft file connectorMulesoft file connector
Mulesoft file connectorkumar gaurav
 
Mule agent notifications
Mule agent notificationsMule agent notifications
Mule agent notificationsShanky Gupta
 
Until successful component in mule demo
Until successful component in mule demoUntil successful component in mule demo
Until successful component in mule demoSudha Ch
 
Using mule with web services
Using mule with web servicesUsing mule with web services
Using mule with web servicesShanky Gupta
 
For each component in mule demo
For each component in mule demoFor each component in mule demo
For each component in mule demoSudha Ch
 
Automatic documentation with mule
Automatic documentation with muleAutomatic documentation with mule
Automatic documentation with muleF K
 
Runing batch job in mule
Runing batch job in muleRuning batch job in mule
Runing batch job in muleSon Nguyen
 
Scatter gather flow in mule
Scatter gather flow in muleScatter gather flow in mule
Scatter gather flow in muleSon Nguyen
 

What's hot (20)

Introduction to testing mule
Introduction to testing muleIntroduction to testing mule
Introduction to testing mule
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interface
 
Concepts in mule
Concepts in muleConcepts in mule
Concepts in mule
 
Mule maven
Mule mavenMule maven
Mule maven
 
Mule batch job
Mule batch jobMule batch job
Mule batch job
 
Routing in mule
Routing in muleRouting in mule
Routing in mule
 
Choice component in mule
Choice component in mule Choice component in mule
Choice component in mule
 
Mulesoft file connector
Mulesoft file connectorMulesoft file connector
Mulesoft file connector
 
Mule agent notifications
Mule agent notificationsMule agent notifications
Mule agent notifications
 
Mule esb
Mule esbMule esb
Mule esb
 
Until successful component in mule demo
Until successful component in mule demoUntil successful component in mule demo
Until successful component in mule demo
 
Using mule with web services
Using mule with web servicesUsing mule with web services
Using mule with web services
 
For each component in mule demo
For each component in mule demoFor each component in mule demo
For each component in mule demo
 
Automatic documentation with mule
Automatic documentation with muleAutomatic documentation with mule
Automatic documentation with mule
 
Data weave in mule
Data weave in muleData weave in mule
Data weave in mule
 
Runing batch job in mule
Runing batch job in muleRuning batch job in mule
Runing batch job in mule
 
Mule soap
Mule soapMule soap
Mule soap
 
Dynamic file attribute
Dynamic file attributeDynamic file attribute
Dynamic file attribute
 
Scatter gather flow in mule
Scatter gather flow in muleScatter gather flow in mule
Scatter gather flow in mule
 
Mule soap
Mule soapMule soap
Mule soap
 

Viewers also liked

Código de comercio
Código de comercioCódigo de comercio
Código de comercioMaribel Yong
 
UPDATED CV OF MARILYN BYARD
UPDATED CV OF MARILYN BYARDUPDATED CV OF MARILYN BYARD
UPDATED CV OF MARILYN BYARDMarilyn Byard
 
Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"
Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"
Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"Ministério da Saúde
 
Ley4615
Ley4615Ley4615
Ley4615EPRE
 
Porcentaje de preferencias
Porcentaje de preferenciasPorcentaje de preferencias
Porcentaje de preferenciasIsiAlvarez
 
New Media Driver's License Final Presentation
New Media Driver's License Final PresentationNew Media Driver's License Final Presentation
New Media Driver's License Final PresentationJordan Sweat
 

Viewers also liked (14)

Código de comercio
Código de comercioCódigo de comercio
Código de comercio
 
Tendencias y enfoque innovadores
Tendencias y enfoque innovadoresTendencias y enfoque innovadores
Tendencias y enfoque innovadores
 
Mi vida
Mi vidaMi vida
Mi vida
 
UPDATED CV OF MARILYN BYARD
UPDATED CV OF MARILYN BYARDUPDATED CV OF MARILYN BYARD
UPDATED CV OF MARILYN BYARD
 
Proposal defense2
Proposal defense2Proposal defense2
Proposal defense2
 
Alcoholyounghscer340
Alcoholyounghscer340Alcoholyounghscer340
Alcoholyounghscer340
 
La honestidad
La honestidadLa honestidad
La honestidad
 
Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"
Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"
Número de pessoas que bebem antes de dirigir segue caindo, após "Lei Seca"
 
Ley4615
Ley4615Ley4615
Ley4615
 
Am mama
Am mamaAm mama
Am mama
 
Porcentaje de preferencias
Porcentaje de preferenciasPorcentaje de preferencias
Porcentaje de preferencias
 
293
293293
293
 
IDS No Estructural
IDS No EstructuralIDS No Estructural
IDS No Estructural
 
New Media Driver's License Final Presentation
New Media Driver's License Final PresentationNew Media Driver's License Final Presentation
New Media Driver's License Final Presentation
 

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 esbRaviShankar Mishra
 
Email configuration in mule esb
Email configuration in mule esbEmail configuration in mule esb
Email configuration in mule esbVamsi Krishna
 
Mule connectors-part 1
Mule connectors-part 1Mule connectors-part 1
Mule connectors-part 1VirtusaPolaris
 
Adding dynamic file
Adding dynamic fileAdding dynamic file
Adding dynamic fileSon Nguyen
 
File component in mule demo
File component in mule demoFile component in mule demo
File component in mule demoSudha Ch
 
Mule ESB Components
Mule ESB Components Mule ESB Components
Mule ESB Components pat_91
 
XML Tutor maXbox starter27
XML Tutor maXbox starter27XML Tutor maXbox starter27
XML Tutor maXbox starter27Max Kleiner
 
File component in mule
File component in muleFile component in mule
File component in muleRajkattamuri
 
File component
File component File component
File component F K
 
File component in mule
File component in muleFile component in mule
File component in mulejaveed_mhd
 
Elements in a muleflow
Elements in a muleflowElements in a muleflow
Elements in a muleflowThang Loi
 

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
 
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
 
File component in mule demo
File component in mule demoFile component in mule demo
File component in mule demo
 
Mule ESB
Mule ESBMule ESB
Mule ESB
 
Mule ESB Components
Mule ESB Components Mule ESB Components
Mule ESB Components
 
XML Tutor maXbox starter27
XML Tutor maXbox starter27XML Tutor maXbox starter27
XML Tutor maXbox starter27
 
mulesoft
mulesoftmulesoft
mulesoft
 
File component
File component File component
File component
 
Mule File component
Mule File component Mule File component
Mule File component
 
File component in mule
File component in muleFile component in mule
File component in mule
 
File component
File component File component
File component
 
File component in mule
File component in muleFile component in mule
File component in mule
 
File component
File componentFile component
File component
 
Splitter
SplitterSplitter
Splitter
 
Web services
Web servicesWeb services
Web services
 
Setting filedynamically
Setting filedynamicallySetting filedynamically
Setting filedynamically
 
Elements in a muleflow
Elements in a muleflowElements in a muleflow
Elements in a muleflow
 

More from irfan1008

Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformerirfan1008
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeirfan1008
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community editionirfan1008
 
Groovy with Mule
Groovy with MuleGroovy with Mule
Groovy with Muleirfan1008
 
Validate Soap Request in Mule
Validate Soap Request in MuleValidate Soap Request in Mule
Validate Soap Request in Muleirfan1008
 
WebService with VM Mule
WebService with VM MuleWebService with VM Mule
WebService with VM Muleirfan1008
 
Xslt in mule
Xslt in muleXslt in mule
Xslt in muleirfan1008
 
Developing Oracle Connector Using Mule
Developing Oracle Connector Using MuleDeveloping Oracle Connector Using Mule
Developing Oracle Connector Using Muleirfan1008
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectorsirfan1008
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectorsirfan1008
 
Mule execution
Mule executionMule execution
Mule executionirfan1008
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectorsirfan1008
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processingirfan1008
 
Mule architecture
Mule architectureMule architecture
Mule architectureirfan1008
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchangeirfan1008
 
Mule security saml
Mule security samlMule security saml
Mule security samlirfan1008
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaasirfan1008
 

More from irfan1008 (20)

Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Mule
MuleMule
Mule
 
Groovy with Mule
Groovy with MuleGroovy with Mule
Groovy with Mule
 
Validate Soap Request in Mule
Validate Soap Request in MuleValidate Soap Request in Mule
Validate Soap Request in Mule
 
WebService with VM Mule
WebService with VM MuleWebService with VM Mule
WebService with VM Mule
 
Xslt in mule
Xslt in muleXslt in mule
Xslt in mule
 
Developing Oracle Connector Using Mule
Developing Oracle Connector Using MuleDeveloping Oracle Connector Using Mule
Developing Oracle Connector Using Mule
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectors
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectors
 
Mule execution
Mule executionMule execution
Mule execution
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectors
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
Mule architecture
Mule architectureMule architecture
Mule architecture
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchange
 
Mule soap
Mule soapMule soap
Mule soap
 
Mule soa
Mule soaMule soa
Mule soa
 
Mule security saml
Mule security samlMule security saml
Mule security saml
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaas
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Send email attachment using smtp in mule esb

  • 1. Send email attachment using SMTP in Mule ESB
  • 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.