将所有发出的电子邮件重定向到单个地址进行测试 [英] Redirect all outgoing emails to single address for testing

查看:178
本文介绍了将所有发出的电子邮件重定向到单个地址进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Ruby on Rails中,我处于某种情况,我希望我的应用程序(在特定的测试环境中)拦截应用程序生成的所有发出的电子邮件,而是将它们发送到不同的测试地址(也可能是修改身体说最初发送到...)。



我看到ActionMailer有一些挂钩来观察或拦截邮件,但是我不想旋转自己的解决方案,如果有一个更简单的方法来做到这一点。我们正在使用 sanitize_email 宝石有很大的成功。它将所有电子邮件发送到您指定的地址,并使用原始收件人添加主题。这听起来像是你想要的,使我们的QA电子邮件变得轻而易举。


In Ruby on Rails, I'm in a situation where I'd like my application (in a particular testing environment) to intercept all outgoing emails generated by the application and instead send them to a different, testing address (maybe also modifying the body to say "Initially sent to: ...").

I see ActionMailer has some hooks to observe or intercept mail, but I don't want to spin my own solution if there's an easier way to do this. Suggestions?

解决方案

We're using the sanitize_email gem with much success. It sends all email to an address you specify and prepends the subject with the original recipient. It sounds like it does exactly what you want and has made QA-ing emails a breeze for us.

这篇关于将所有发出的电子邮件重定向到单个地址进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆