Over a million developers have joined DZone.

Email Connector in Mule 4.0

DZone's Guide to

Email Connector in Mule 4.0

This tutorial will explain the email connector send operation in Mule 4.0 with new Anypoint Studio.

· Integration Zone ·
Free Resource

SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.

Step 1: Create a New Mule Project named SmptDemo

  • Drag and drop an HTTP Listener Connector to get the request for your service and set the host and port numbers. Here, the host is set to mule4.eaiesb.com and port to 9098 and after configuring, test the connection successfully will specify port is in use or not.
  • Set the URL path for your email service: / and get the message in the body field of your response property.
  • By default Mule 4.0 doesn't have the email Module so in Mule palette click on +Add Module and add the email extension from the list and finish it.

Step 2: Add the Extension and Verify the Following in the Palette 

  • The earlier Mule version has three different connectors for mail like IMAP, POP3, and SMTP, but the Mule 4.0 version has a single email module that has different operations like Delete, Send, List pop 3, List imap as shown below:

Image title

Step 3:

Drag the email connector onto the canvas and configure the SMTP settings. Here, the configuration is Host: smtp.gmail.com , Port: 587 , User: muletest@eaiesb.com and password details of the SMTP as shown:

Image title

  • Go to the Advanced tab and select inline from properties field and add the following:
    • Key: mail.smtp.starttls.enable & Value: true and test that connection is successful.

Image title

Step 4: Give the From address within that To address, Subject, and Body details. Select the Content as text here: Hello Mule4 and ContentType as text/plain.

Image title

Setting the Body and Content below:

Image title

Step 5:

Right-click on canvas and run the Mule Project, and by default, Mule will download the artifacts from the maven repository, and once the project does not have any errors, it will show a successful deployment.

Step 6:

Open the Postman and Hit the Service URL request as shown:

Image title

  • The message is sent successfully in HTTP response property, and the response set for the request, and we can check the message given in the body within the mail ID set in Value of SMTP Connector and is successfully received as mail body:

Image title

Happy learning!

With SnapLogic’s integration platform you can save millions of dollars, increase integrator productivity by 5X, and reduce integration time to value by 90%. Sign up for our risk-free 30-day trial!

mule 4 ,integration ,anypoint ,email connector

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}