Spring Book – Chapter 20 – Spring Integration

Email

Spring Integration supports various e-mail protocols available today in the industry, allowing sending of e-mail based on incoming channel messages and the receiving of e-mails as channel messages. We will now discuss IMAP, POP3, and SMTP examples in detail in this section. Listing 22-61 shows the main dependency required for supporting Spring Integration email in your application.

Listing 22-61. Maven dependency required

Listing 22-62 below shows configuration of main Spring Integration namespace and mail related namespace in the Spring configuration file (mail-integration-context.xml).

Listing 22-62. Spring Integration Namespace declaration

IMAP

The mail inbound channel adapter support both the IMAP and POP3 mail protocol. Listing 22-63 below shows configuring of mail inbound channel adapter to configure Gmail and to receive messages using IMAP protocol.

Listing 22-63. Configuring mail inbound channel adapter using IMAP

POP3

Listing 22-64 below shows configuring of mail inbound channel adapter to configure Gmail and to receive messages using POP3 protocol.

Listing 22-64. Configuring mail inbound channel adapter using POP3

SMTP

The mail outbound channel adapter uses the SMTP protocol to send e-mail messages. According to the message mapping strategies, if the input message payload is an instance of the org.springframework.mail.MailMessage interface, it will be sent directly as text message and if the input message is a byte array it will be sent as an e-mail attachment. The mail outbound channel adapter can be configured in two ways as shown in Listing 22-65 and Listing 22-66 below.

Listing 22-65. Configuring mail outbound channel adapter using channel and mail sender

Listing 22-66. Configuring mail outbound channel adapter using host, it’s username and password

Page Visitors: 12162

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

2 thoughts on “Spring Book – Chapter 20 – Spring Integration

  1. Hi,
    Thanks for this blog and information sharing!
    I have one question from Spring Integration. Just thought of checking with you.
    I have SimplewebserviceOutBoundGateway. I need to send a document / attachment to the webservice. How will i achieve that?
    This is my current gateway configuration:

    Please let me know, if you can throw some light in this area.
    Thanks in Advance!

  2. Hi,
    Thank you for your information sharing.
    I have one doubt,could you please suggest me the correct frameworks to address that issue.

    My requirement is I would like to get and process files using spring and camel.

    Thanks,
    Madhu

Leave a Reply

Your email address will not be published. Required fields are marked *