Rails: test mailgun on localhost

≯℡__Kan透↙ 提交于 2019-12-23 15:54:00

问题


I have a Rails app running on Heroku that uses Mailgun to process incoming emails. I haven't been able to figure how I can debug my email processing locally (on localhost) instead of having to push everything up to heroku every time I make a change. (this is just a test app - I'm the only one using it)

Is it possible to work with Mailgun locally? If so, how do I go about it?

Thank you in advance


回答1:


Mailgun gives you the option to store a message for later retrieval. If you configure it that way, you'll be able to fetch messages from development for processing without having to set up a publicly-accessible webhook for Mailgun to hit.

But I'm assuming you have production configured with an HTTP endpoint, and it's no fun to do things differently between environments. There are a few tools that will let you set up a public endpoint that routes to localhost:

  • ngrok, which I've used to good effect to test Twilio. You can set up a permanent subdomain so you don't have to constantly change your Mailgun configuration.
  • UltraHook, which I haven't personally used, but looks the same.
  • Localtunnel which looks easiest to start up, but like you get a different host at every boot.

If you have a permanent publicly-accessible server, you can also maintain your own tunnel.




回答2:


mailgun provides a sandbox that you can use for localhost the only downside to this is that you have to add the test email to valid recipient.



来源:https://stackoverflow.com/questions/31893881/rails-test-mailgun-on-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!