我想邀請我的應用程序來自邀請者而不是系統電子郵件地址。我如何覆蓋devise.rb中的config.mailer_sender?在devise_invitable中忽略郵件?
我在我的郵件中有這個,並且已經確認它已經被調用,但是它不覆蓋:from
。注意:這是一個私有方法,我嘗試了它作爲一個公共方法,沒有任何效果。
private
def headers_for(action)
if action == :invitation_instructions
headers = {
:subject => "#{resource.invited_by.full_name} has invited you to join iTourSmart",
:from => resource.invited_by.email,
:to => resource.email,
:template_path => template_paths
}
else
headers = {
:from => mailer_sender(devise_mapping),
:to => resource.email,
:template_path => template_paths
}
end
if resource.respond_to?(:headers_for)
headers.merge!(resource.headers_for(action))
end
unless headers.key?(:reply_to)
headers[:reply_to] = headers[:from]
end
headers
end
該動作不應該是':invitation_instructions'嗎?我相信你有一個額外的s,因爲你的代碼說:'invitations_instructions' – swrobel
它應該是,謝謝,但錯字是一致的,所以這不是問題。我將編輯這個問題來澄清。 –