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 is detected. All of this can be done without changing a single line of our GoMail example application GUIs. In fact, to activate a real Gmail account instead of our test server "we need to change the client.NewTestServer() function call to client.NewGmailServer() (a full description of this Gmail provider is available in the final Appendix, Connecting GoMail to a Real Email Server).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.73.175