]> git.openstreetmap.org Git - rails.git/blob - config/initializers/action_mailer.rb
Merged I18N branch to head.
[rails.git] / config / initializers / action_mailer.rb
1 # Configure ActionMailer SMTP settings
2 ActionMailer::Base.smtp_settings = {
3   :address => 'localhost',
4   :port => 25, 
5   :domain => 'localhost',
6 }
7
8 # Monkey patch to fix return-path bug in ActionMailer 2.2.2
9 # Can be removed once we go to 2.3
10 module Net
11   class SMTP
12     def sendmail(msgstr, from_addr, *to_addrs)
13       send_message(msgstr, from_addr.to_s.sub(/^<(.*)>$/, "\\1"), *to_addrs)
14     end
15   end
16 end
17
18 # Monkey patch to allow sending of messages in specific locales
19 module ActionMailer
20   class Base
21     adv_attr_accessor :locale
22   private
23     alias_method :old_render_message, :render_message
24
25     def render_message(method_name, body)
26       old_locale= I18n.locale
27
28       begin
29         I18n.locale = @locale
30         message = old_render_message(method_name, body)
31       ensure
32         I18n.locale = old_locale
33       end
34
35       message
36     end
37   end
38 end