New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send multipart emails #2341

Closed
tmaier opened this Issue Mar 22, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@tmaier

tmaier commented Mar 22, 2013

Since #1326 devise has markerb support, which is great.

Unfortunately, it just sends the HTML email, as the call to mail at https://github.com/plataformatec/devise/blob/master/lib/devise/mailers/helpers.rb#L16 does not have a block, like

    mail(:to => @recipient, :from => "john.doe@example.com") do |format|
      format.text
      format.html
    end

https://github.com/plataformatec/markerb

@lucasmazza

This comment has been minimized.

Show comment
Hide comment
@lucasmazza

lucasmazza Mar 24, 2013

Contributor

@tmaier yeah, it won't work out of the box. Currently the best solution is to override the mailer in your application with a custom devise_mail implementation:

 def devise_mail(record, action, opts={})
  initialize_from_record(record)
  mail(headers_for(action, opts)) do |format|
    format.text
    format.html
  end
end

Devise could support this out of the box, but it would require that we provide .text templates by default to all mailers - otherwise the format block inside the Devise mailer would fail - but I don't think that would be a sustainable idea. Maybe the views generator should output some information about this required change. What do you think? If you got any other idea feel free to submit a PR or discuss this further - But for the moment I'm closing this one.

Thanks!

Contributor

lucasmazza commented Mar 24, 2013

@tmaier yeah, it won't work out of the box. Currently the best solution is to override the mailer in your application with a custom devise_mail implementation:

 def devise_mail(record, action, opts={})
  initialize_from_record(record)
  mail(headers_for(action, opts)) do |format|
    format.text
    format.html
  end
end

Devise could support this out of the box, but it would require that we provide .text templates by default to all mailers - otherwise the format block inside the Devise mailer would fail - but I don't think that would be a sustainable idea. Maybe the views generator should output some information about this required change. What do you think? If you got any other idea feel free to submit a PR or discuss this further - But for the moment I'm closing this one.

Thanks!

@lucasmazza lucasmazza closed this Mar 24, 2013

@arturoherrero

This comment has been minimized.

Show comment
Hide comment
@arturoherrero

arturoherrero Jan 27, 2015

How about create a custom mailer for devise like this:

class MyMailer < Devise::Mailer
  default parts_order: [ "text/plain", "text/html" ]
end

arturoherrero commented Jan 27, 2015

How about create a custom mailer for devise like this:

class MyMailer < Devise::Mailer
  default parts_order: [ "text/plain", "text/html" ]
end

3wille added a commit to 3wille/devise that referenced this issue Jul 13, 2016

add block passthrough to devise_mail
ActionMailer's ``mail`` method may receive a block for customizing the mails
format
``devise_mail`` now has the same functionality by just
passing the block to ``mail`` call.

fixes plataformatec/devise#2341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment