I have done this on a different platform. It is complex. Here are the steps in a nutshell.
Set up an e-mail domain and parser. If you want a shortcut, there are services like Sendgrid that will receive e-mail for you and deliver them to you by HTTP API with all the parts separated out into...