Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise mail template for reset password

I want to add attachment to email sent on reseting password by devise (logo image) and also I want to use user's locale to localize email text. Can anybody help and tell me what to override to do this?

like image 294
link_er Avatar asked Apr 13 '12 14:04

link_er


3 Answers

You need to add the logo image as an attachment.

To do so, follow the instructions in the link to override the default Devise::Mailer: https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer

Then, add the attachment using attachments.inline['logo.png']=:

def reset_password_instructions(record, opts={})
  attachments.inline['logo.png'] = File.read('app/assets/images/logo.png')
  super(record, opts)
end

And in the view you can use attachments['logo.png'].url:

<%= image_tag(attachments['logo.png'].url, alt: 'Logo') %>
like image 67
haejeong87 Avatar answered Nov 01 '22 18:11

haejeong87


just run rails generate devise:views and edit template in app/views/devise/mailer/reset_password_instructions.html.erb

like image 20
Vasiliy Ermolovich Avatar answered Nov 01 '22 18:11

Vasiliy Ermolovich


I'm using devise 4.3 for rails 5 app. Additional argument is required.

 def reset_password_instructions(record, token, opts={})
    attachments.inline['logo.png'] = File.read("#{Rails.root}/app/assets/images/logo.png")
    super(record, token, opts)
 end
like image 2
Nithin Avatar answered Nov 01 '22 20:11

Nithin