Incoming messages
The client API that has been used to simulate a connection to an email server included the Incoming() function, which returned a channel of EmailMessage objects. A new message would be sent to this channel each time a new email arrived, and we can use this same model for a real email server connection as well. The email message abstraction works to communicate a standard structure and so all a new email connection (such as the preceding Gmail examples) needs to do is package the incoming data into an EmailMessage struct and add it to the channel.
This means the only additional work that we need to do is update the code in the server connection package to monitor for new messages and add some JSON decoding when a new message ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access