Implementing a Mailgun-Inspired Webhook

I am looking into creating a simple webhook that can capture incoming emails. My plan is to implement this using either Python or JavaScript, and I’m considering embedding the webhook logic within an HTML page on my website so that the received emails are stored directly on my server. Has anyone implemented a similar solution or could provide example code to help me get started? Any guidance or sample implementations would be greatly appreciated.