advanced-mail-connectivity-receive-email-mailserver
Version 17.1 by marijn on 2022/05/05 16:14
Receive emails
We explained the MIME protocol in a previous [microlearning](advanced-mail-connectivity-whatis-mime.md). In this microlearning, we will expand our knowledge by learning how to receive emails with the help of MIME messages via the eMagiz platform.Should you have any questions, please get in touch with academy@emagiz.com.- Last update: January 27th, 2022
- Required reading time: 6 minutes
1. Prerequisites
- Advanced knowledge of the eMagiz platform
- Understanding of the MIME concept
2. Key concepts
- There are two options when retrieving emails (IMAP and standard)
- Use IMAP when you want to listen and wait for emails to be pushed to eMagiz
- Use standard mail when you actively want to poll for messages
- Both options have a MIME output that should be transformed to XML for further processing
3. Receive emails
We explained the MIME protocol in a previous [microlearning](advanced-mail-connectivity-whatis-mime.md). In this microlearning, we will expand our knowledge by learning how to receive emails with the help of MIME messages via the eMagiz platform.When you want to receive emails from an email server, you have two options in eMagiz. The two options are IMAP and "standard" mail. The difference between the two is that you listen to a particular mailbox with the IMAP component and wait till email messages are pushed to you. However, the "standard" mail component allows you to actively poll at a frequency most suited to you to see whether there are new mails that need to be processed.Regardless of which of the two options you end up choosing, note that both have a MIME message as output. To further process the information within the MIME message, you most likely will need a MIME to XML transformation. Exceptions to this might be any mail solution in which the attachments are significant for data processing. In those cases, you might need to consider a different approach.In the remainder of this microlearning, we will zoom in on how you should configure both options within a flow in eMagiz.3.1 IMAP
As stated above, the IMAP option allows you to listen to a specific mailbox and wait till mail messages are pushed to eMagiz. To configure this in eMagiz, we need to open a flow in eMagiz and enter "Start Editing" mode. The first component we need is an IMAP idle channel adapter. Search for the component by typing in IMAP to select the suitable component. Once you have found the component, please drag it onto the canvas.



3.2 "Standard" mail
As stated above, the "standard" mail option allows you to poll at your interval to check whether new messages have arrived. To configure this in eMagiz, we need to open a flow in eMagiz and enter "Start Editing" mode. The first component we need is a "Mail inbound channel adapter." Select the category inbound channel adapter and search for mail. Once you have the component, please drag it onto the canvas.



Practice
4. Assignment
Build two flows that can receive emails. One flow should use the IMAP configuration, and the other should use the "standard" configuration. This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment.5. Key takeaways
- There are two options when retrieving emails (IMAP and standard)
- Use IMAP when you want to listen and wait for emails to be pushed to eMagiz
- Use standard mail when you actively want to poll for messages
- Both options have a MIME output that should be transformed to XML for further processing
6. Suggested Additional Readings
If you are interested in this topic and want more information, please read the release notes and help texts provided by eMagiz. Furthermore, check out the following links:- https://docs.spring.io/spring-integration/docs/2.1.x/reference/html/mail.html#mail-inbound
- https://docs.spring.io/spring-integration/reference/html/mail.html