Rails ActionMailer - format sender and recipient name/email address

后端 未结 6 1248
耶瑟儿~
耶瑟儿~ 2020-12-04 09:44

Is there a way to specify email AND name for sender and recipient info when using ActionMailer?

Typically you\'d do:

@recipients   = \"#{user.email         


        
6条回答
  •  囚心锁ツ
    2020-12-04 10:02

    Another irritating aspect, at least with the new AR format, is to remember that 'default' is called on the class level. Referencing routines that are instance-only causes it to silently fail and give when you try to use it:

     NoMethodError: undefined method `new_post' for Notifier:Class
    

    Here's what I ended up using:

    def self.named_email(name,email) "\"#{name}\" <#{email}>" end
    default :from => named_email(user.name, user.email)
    

提交回复
热议问题