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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

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
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

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Kafka JDBC Source Connector for Large Data
  • Make Your Integration Seamless By Using Ballerina Client Connectors
  • How to Integrate a Distributed Database With Event Streaming
  • Configuring a Shopify MuleSoft Connector

Trending

  • DZone's Cloud Native Research: Join Us for Our Survey (and $750 Raffle)!
  • PostgresML: Streamlining AI Model Deployment With PostgreSQL Integration
  • OWASP Top 10 Explained: SQL Injection
  • Python for Beginners: An Introductory Guide to Getting Started

Mule Email Connector

This article will guide you through the steps of how to use an email connector in the Mule Application. Read below for the tutorial!

By 
Karan Gupta user avatar
Karan Gupta
·
Jan. 25, 22 · Tutorial
Like (3)
Save
Tweet
Share
6.1K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we are going to explore all the features provided by mule Email Connector. Email connector helps you to Send, Mark, List, and Delete Emails. We see a simple demo for each of these features now. 

Before starting with developing the Mule Application we need to do some configuration settings in the Gmail account. 

  1. Open your Gmail account and navigate to  Settings --> See all settings options.
  2. Now navigate to forwarding to POP/IMAP option to enable it.
  3. Once this is done, now we need to open Google Account and enable the Less Secure App access, for which go to Manage your Google Account and in search box type Less Secure App access.
  • Now we are ready to start. Open your Anypoint Studio and drag and drop Email Connector from Add Modules as below.
    • Send: 
      • Send Email connector helps you to send mail over SMTPs server. You can also send Attachments through this. Let us configure the connector now.
      • Drag and drop Http Listner and Send Email Connector in a flow and configure the same.
      • Now Configure both the components as below.
        • HTTP Listner Config:
        • Send Mail Config: While configuring this make sure you select connection as SMTPS connection and also tick the Insecure checkbox.
        • Now, we need to configure Send Components properties.
          • If you want to send an attachment you need to define the file extension in the Attachment section. In our demo, we will be sending a .txt file as an attachment. 
          • Also, you can send multiple files as attachments. 
          • Now from Postman hit the above application and you will see an Email in your inbox with one attachment.
    • List:
      • This will give the List of emails available in your mailbox. You can list all the emails or filter it based on certain options provided by the connector. We are going to use the List IMAP component to list available mails in our mailbox.
      • Below is the Flow and Respective connector configuration:
        • List IMAP Config: While configuring this make sure you select IMAPS connection and also tick the Insecure checkbox.
        • In the properties config, you can set the Match with the filter to do the filtering. Also, you can restrict the number of emails you want to retrieve by setting the limit value, -1 indicates all the mails. 
      • Now, from the postman, hit the above application and you will see the list of emails there in your inbox. Check the output it has attachments and attributes with all the details.
      • JSON
         
        [
            {
                "inboundAttachmentNames": [],
                "exceptionPayload": null,
                "inboundPropertyNames": [],
                "outboundAttachmentNames": [],
                "payload": {
                    "attachments": {
                        "hello.txt": "Hello"
                    },
                    "body": "Test"
                },
                "outboundPropertyNames": [],
                "attributes": {
                    "headers": {
                        "Return-Path": "<givetest157@gmail.com>",
                        "Received": "",
                        "From": "givetest157@gmail.com",
                        "To": "givetest157@gmail.com",
                        "Message-ID": "",
                        "Date": "Fri, 14 Jan 2022 14:42:11 +0530 (IST)",
                        "Subject": "Test",
                        "MIME-Version": "1.0",
                        "Content-Type": "multipart/mixed;\r\n boundary=\"----=_Part_0_1243330334.1642151531229\""
                    },
                    "subject": "Test",
                    "flags": {
                        "answered": false,
                        "seen": true,
                        "deleted": false,
                        "draft": false,
                        "recent": false
                    },
                    "ccAddresses": [],
                    "fromAddresses": [
                        "givetest157@gmail.com"
                    ],
                    "bccAddresses": [],
                    "toAddresses": [
                        "givetest157@gmail.com"
                    ],
                    "number": 1,
                    "sentDate": "2022-01-14T14:42:11",
                    "id": "25",
                    "replyToAddresses": [
                        "givetest157@gmail.com"
                    ],
                    "receivedDate": "2022-01-14T14:42:15"
                }
            }
        ]

         

    • Mark as Read:

      • This will mark the emails in your inbox to read. In this, we need to first fetch the Mail id using the List mail component and then pass that id to Mark as a read component for this activity. Below is the flow and the config:

      • Mark as Read Config: You need to use the same connection config we created above for List mails. In the properties, section pass the id received in the output of the List mail component.

      • Now run the code and you will see the mail in your inbox marked as read.

    • Mark as Delete:

      • Marks an incoming email as Deleted. Emails that are marked for deletion are scheduled for deletion when the folder closes, which means that the email is not physically eliminated from the mailbox folder, but its state changes.

      • All these marked emails are deleted when the Delete or Expunge folder is executed.

        • Mark as Deleted config: 

    • Delete: 

      • This will delete the email with the specified email id from the inbox.

      • Also, this will delete the emails that were marked as deleted. 

Connector (mathematics)

Opinions expressed by DZone contributors are their own.

Related

  • Kafka JDBC Source Connector for Large Data
  • Make Your Integration Seamless By Using Ballerina Client Connectors
  • How to Integrate a Distributed Database With Event Streaming
  • Configuring a Shopify MuleSoft Connector

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: