DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Sending outbound SMTP messages through Gmail with Mule ESB

Sending outbound SMTP messages through Gmail with Mule ESB

Rod Biresch user avatar by
Rod Biresch
·
Jul. 25, 10 · Interview
Like (0)
Save
Tweet
Share
21.84K Views

Join the DZone community and get the full member experience.

Join For Free

I'm currently working on a Managed File Transfer (MFT) proof-of-concept for a client using Mule ESB Enterprise.  One of the requirements I had to address is the ability to send SMTP email messages when a particular connector failed, i.e. SFTP connection failed.  I thought to myself, that's a reasonable request and something that is probably straightforward to do in Mule ESB.  Well, if you look at the Mule configuration it is straightforward however, getting to that point using Gmail took some work...so I thought I'd share :)

What you need...

  • Mule ESB (I'm using Mule ESB Enterprise Version: 2.2.5 Build: 16813 along with Mule Management Console support, i.e. mmc-agent-2.2.5.jar) *
  • A test Gmail account
* - if you plan on running the same version I am then there is a patch that needs to be applied to the mmc-agent-2.2.5.jar.  See JIRA issue MULE-4970.

Mule Configuration...
<?xml version="1.0"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:file="http://www.mulesource.org/schema/mule/file/2.2"
xmlns:smtp="http://www.mulesource.org/schema/mule/smtp/2.2"
xmlns:email="http://www.mulesource.org/schema/mule/email/2.2"
xsi:schemaLocation="http://www.mulesource.org/schema/mule/core/2.2
http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/file/2.2
http://www.mulesource.org/schema/mule/file/2.2/mule-file.xsd
http://www.mulesource.org/schema/mule/smtp/2.2
http://www.mulesource.org/schema/mule/smtp/2.2/mule-smtp.xsd
http://www.mulesource.org/schema/mule/email/2.2
http://www.mulesource.org/schema/mule/email/2.2/mule-email.xsd">

<description>Test configuration to send SMTP email through Gmail.</description>

<!-- Configure some properties to work with GMail's SMTP -->
<smtp:gmail-connector name="emailConnector" />

<model name="processInboundFileModel">
<service name="processInboundFileService">
<inbound>
<file:inbound-endpoint
path="./remoteFS">
</file:inbound-endpoint>
</inbound>

<echo-component/>

<outbound>
<pass-through-router>
<smtp:outbound-endpoint
connector-ref="emailConnector"
host="smtp.gmail.com"
port="587"
user="<account name>%40gmail.com"
password="<password>"
to="<email addresses>"
from="<account name>@gmail.com"
subject="Test email message"/>
</pass-through-router>
</outbound>
</service>
</model>
</mule>


As indicated, the Mule configuration is very straightforward.  You can get most of the information you need from the Mule SMTP Transport documentation except for what Gmail port to use and most importantly the gmail-connector information.  That tripped me up for a while until I came across a Mule JIRA issue where someone refer to the configuration in the bookstore example for sending email through Gmail.  I still haven't found much information on this connector and what it's doing but it does work and you need to use in order to connect to Gmail.

One other thing that is documented however maybe overlooked is that you need to replace the "@" symbol in the "user" attribute with the URL escape code of "%40".

Cheers!

 

From http://soatechlab.blogspot.com/2010/07/sending-outbound-smtp-messages-through.html

Enterprise service bus Gmail

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Host Hack Attempt Detection Using ELK
  • How To Best Use Java Records as DTOs in Spring Boot 3
  • Java REST API Frameworks
  • Detecting Network Anomalies Using Apache Spark

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: