This project is archived and is in readonly mode.

#1936 ✓resolved
Justin French

Emails with attachments don't work as documented

Reported by Justin French | February 11th, 2009 @ 04:11 AM | in 2.x

Trying to send an email which has both a plain text body and a file attachment, as shown in the documentation for ActionMailer, but the local assigns are nil when the body view is rendered.

Have been speaking with Koz about this elsewhere for a little while and we decided to add it here as a ticket instead.

I've attached a full sample app, but here's the mailer:


class Mail < ActionMailer::Base
  
  def daily_report
    recipients      "me@example.com"
    subject         "Daily Report"
    from            "me@example.com"
    content_type    "multipart/alternative"
    
    part :content_type => "text/plain", 
         :body => render_message("daily_report", :date => Time.now, :recipient => "Bob")

    attachment :content_type => "text/csv", :filename => "hello", :body => "my,cool,csv"
    
  end

end

And the view:


<%= @recipient %>,

Please see the attached report, created for <%= @date.strftime("%Y %m %d") %>.

An error is raised on nil.strftime, which I think means the local assigns are not working as advertised.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages