Email

  • Description: the Mail component is used for sending and receiving emails. It is often divided into three main protocols:

    • IMAP for accessing and managing emails on the server.

    • POP3 for downloading emails from the server.

    • SMTP for sending emails.

IMAP/IMAPS

  • Description: the IMAP protocol is used to receive emails, allowing access to multiple mail folders and handling messages directly on the server.

    Note IMAPS is a secure version of IMAP that transmits encrypted data using SSL/TLS.
  • Example

    • The flow is triggered every 60 seconds by the Scheduler.

    • On each execution, it connects to Gmail’s IMAP server using the provided credentials and retrieves unread emails from the "INBOX" folder.

    • Then, it logs the content of the retrieved emails.

Script

Diagram

- from:
    uri: "scheduler:mySchedulerName"
    parameters:
        timeUnit: SECONDS
        delay: 60
    steps:
      - to:
          uri: "imaps://imap.gmail.com:993"
          parameters:
            username: "yourusername"
            password: "yourpassword"
            folder: "INBOX"
            delay: 10000
            includeSeen: false
      - to:
          uri: "log:INFO"
      - log:
          message: "Fetched Email: ${body}"
component imaps connector

POP3/POP3S

  • Description: the POP3 component is used to retrieve emails from POP3 servers, allowing Camel to access the inbox, read the messages, and process them automatically in an integration flow.

    Note POP3S is a secure version of POP3 that transmits encrypted data using SSL/TLS.
  • Example

    • The flow is triggered every 60 seconds by the Scheduler trigger.

    • When the route is triggered, the POP3 connector connects to the Gmail server and attempts to fetch unread emails using the provided credentials.

    • The delete: false parameter indicates that the messages should not be deleted after being read.

    • The unseen: true parameter specifies that only unread messages should be retrieved.

    • After retrieving the emails, the integration uses the log component to log the received information.

    • The showAll: true parameter ensures that all email details, including headers, body, and other relevant information, are displayed in the log.

Script

Diagram

- from:
    uri: "scheduler:emailScheduler"
    parameters:
      delay: "60000"
    steps:
      - to:
          uri: "pop3s://pop.gmail.com:995"
          parameters:
            username: "camelcomponenttest@gmail.com"
            password: "your password"
            delete: false
            unseen: true
      - to:
           uri: "log:email"
           parameters:
             showAll: true
component pop3s connector

SMTP/SMTPS

  • Description: the [SMTP] component is used to send emails to SMTP servers, allowing Camel to send messages with custom content, attachments, and recipients in an integration flow.

    Note SMTPS is a secure version of SMTP that transmits data encrypted using SSL/TLS.
  • Example

    • When a POST request is received at the endpoint /hello, the flow sends an email through the Gmail SMTP server using a secure connection (SMTPS).

    • URI parameters:

      • username: "yourusername": the username of the Gmail account being used for authentication.

      • password: "yourpassword": the password for the Gmail account.

Script

Diagram

- from:
    uri: "rest:post:/hello"
    steps:
    - to:
        uri: "smtps://smtp.gmail.com:465"
        parameters:
          username: "yourusername"
          password: "yourpassword"
component smtps
Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]