在用户邮件中添加多个管理员
Add multiple admin in user mailer
class UserMailer < ActionMailer::Base
default :from => {"admin@abc.com","app@xyz.com"}
end
这是添加多个默认电子邮件帐户的正确方法吗??
Rails 不理解多个 from
地址。您应该为此使用纯字符串,用逗号分隔电子邮件:
default from: [email1, email2, email3].join(',')
不过要小心。我不确定此功能是否广泛 supported。
更新
评论中提出了一个问题,如果 Rails 不支持,为什么要格式化多个地址。我稍微研究了一下,发现了 RFC-2822 规范,section 3.6.2 说明如下:
The from field consists of the field name "From" and a comma-separated list of one or more mailbox specifications.
class UserMailer < ActionMailer::Base
default :from => {"admin@abc.com","app@xyz.com"}
end
这是添加多个默认电子邮件帐户的正确方法吗??
Rails 不理解多个 from
地址。您应该为此使用纯字符串,用逗号分隔电子邮件:
default from: [email1, email2, email3].join(',')
不过要小心。我不确定此功能是否广泛 supported。
更新
评论中提出了一个问题,如果 Rails 不支持,为什么要格式化多个地址。我稍微研究了一下,发现了 RFC-2822 规范,section 3.6.2 说明如下:
The from field consists of the field name "From" and a comma-separated list of one or more mailbox specifications.