我從頭開始一個新的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