我使用 Pony 通过我的 sinatra 应用程序发送电子邮件。但问题 - 我无法弄清楚如何调试或测试它。不用说,在 php 中,您可以配置 sendmail 假应用程序(在 php.ini 中),它将所有传出的电子邮件存储为纯文本文件,其中包含所有数据。
红宝石应用程序怎么样?可能吗?
您肯定已经自己找到了解决方案
在 pony.rb 文件中有这个发送邮件的代码部分:
def self.transport(tmail)
..
end
您可以简单地添加一个方法来返回环境:
def debug?
true #false
end
如果调试模式打开,则做一些特别的事情
def self.transport(tmail)
puts "Debug message" if debug?
if File.executable? sendmail_binary
transport_via_sendmail(tmail)
else
transport_via_smtp(tmail)
end
end