Email send operation via Gmail

  • April 13, 2020

This tech article explains how to send an email using Mule 4 via Gmail integration.

  1. Start by adding a Listener in Mule flow and configuring the Listener configuration
    Email send operation1
  2. Provide a suitable method for a resource. 
  3. Add an email connector in your working space and drag/send email activity to Mule Canvas.
    Email send operation2
  4. Configure the email connector
    Email send operation3

    Username: This is the Gmail ID for which you want to configure SMTP details.

    Password: For this, you need to generate a Google token. Follow the steps below steps to generate a token: 

    1. Enable Gmail 2-step verification: https://www.google.com/landing/2step/
      Email send operation4
    2. Go to https://security.google.com/settings/security/apppasswords and try to generate an app password.
      Email send operation5
    3. Select Mail in the app list, then select your preferred device and generate a token.
      Email send operation6
    4. Paste the token generated in password.
      Email send operation7
  5. On your Mule application, define an SMTP configuration.
    1. Go to the Advanced tab in configuration.
    2. In Properties, select edit inline and set value as follows: 

      Key: “mail.smtp.starttls.enable”

      Value: “True”

      Email send operation8
  6. In mail activity, provide the following info:
    •   To address 
    •   From address
    •   Subject
    •   Body
    • Email send operation9
  7. Build and deploy the application.
  8. Test the application — hit Listener with URL.
    Email send operation10
  9. Check mail.
    Email send operation11

— By Ritendra Dhakciya