How can I debug Mailgun email processing locally in my Rails app?

Can I simulate Mailgun’s email handling on my local Rails setup instead of deploying to a remote environment like Heroku? Looking for local testing tips.

i used ngrok to forward mailgun hooks to my local server; plus mailcatcher to view emails on my machine. works decently for debugging if u tweak a bit!

I have found that setting up a local SMTP emulator like FakeSMTP can also help simulate Mailgun webhooks without relying on an external tunnel. In my Rails app, I configured the development environment to redirect outgoing emails to this local server, so I can monitor incoming requests almost as if they were coming from Mailgun. This method allowed detailed inspection of HTTP headers and email body contents directly in logs, making it easier to identify issues in the email processing pipeline. It’s a reliable alternative to tools such as ngrok for local debugging.

In my experience, I set up a custom endpoint within my Rails development environment to simulate Mailgun callbacks. Instead of relying on external tunneling services, I created a dedicated route that captures incoming POST requests intended for Mailgun and writes the payload to a local log file. This allowed me to inspect and debug email content and headers directly within my application. Although this approach required modifying my local routing and controller logic, it provided a more controlled and repeatable testing scenario. I found it particularly useful for tracking down issues with our email parsing logic before deploying changes.