ActionMailer: Default From: address?

前端 未结 6 1351
-上瘾入骨i
-上瘾入骨i 2020-12-15 07:40

Googled for this to no avail. Didn\'t find anything in the API either. I was expecting some kind of class method or configuration option to set it...

So, rather than

6条回答
  •  -上瘾入骨i
    2020-12-15 08:00

    I went with the monkey-patching method that KandadaBoggu suggested. However, it does not work quite right in Rails 2.3.8; you can't override the default. This works, however:

    def from_with_default(input=nil)
      return instance_variable_set("@from", input) unless input.nil?
      from_without_default || FROM_EMAIL
    end
    alias_method_chain :from, :default
    

提交回复
热议问题