我从头开始一个新的Rails 3应用程序。什么是在Rails中设置自定义全局电子邮件默认值的“最佳实践”方法?
而当我正在经历基本设置(配置宝石,会话等)时,我遇到了一些让我唠叨了一阵子的东西。
我们目前的系统(混合使用Ruby脚本& Rails 2应用程序)向客户端发送各种电子邮件/传真通知。在80%的案例中有一些常见的情况 - cc - 我们终端的某些电子邮件帐户和电子邮件签名。
在environment.rb中以前我刚刚定义GLOBALS如
SYSTEM_EMAIL_SIGNATURE
或
SYSTEM_EMAIL_NOTIFY
,并用它们后来在邮寄或者如果它是一个独立的脚本我有一个设置.rb文件 - 有很多常见的设置 - 包括一个像这样的自定义电子邮件设置。
因为我从头开始重建这个应用程序,并将所有脚本整合到一个ruby应用程序中 - 我试图想到一个更好的方法来做到这一点。
现在我设置了有action_mailer设置的email.rb初始化程序,我伸出通过增加数个项目:
########## Setup Global Email Defaults ##############
Site::Application.configure do
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'mail.example.com',
:port => 25,
:domain => 'example.com',
# These are custom to OUR setup - used later in the code
:default_from => 'it.s[email protected]',
:default_notify => ["[email protected]"],
:default_signature => "
---------------------------
This is an automatic email.
If you have any questions please contact customer service
at 1 (800) 888-0000 or go to http://www.example.com.
Thank you for your business!"
}
end
所以这是一个好办法?或者这两种方法有更好的方法吗?
感谢您的指针! – konung 2010-11-24 15:49:56