Project

General

Profile

Feature #3760 » email-attachments.patch

Brian Crowell, 2011-07-27 22:53

View differences:

app/models/mailer.rb
body :issue => issue,
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
render_multipart('issue_add', body)
issue.attachments.each do |attachment|
part :content_type => `file -ib #{attachment.diskfile}`.gsub(/\n/, ""),
:body => File.read(attachment.diskfile),
:disposition => 'attachment; filename=' + attachment.filename + ';',
:headers => { 'Content-Id' => attachment.filename },
:transfer_encoding => 'base64'
end
end
# Builds a tmail object used to email recipients of the edited issue.
......
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
render_multipart('issue_edit', body)
journal.details.each do |detail|
if detail.property == 'attachment' && attachment = Attachment.find_by_id(detail.prop_key)
part :content_type => `file -ib #{attachment.diskfile}`.gsub(/\n/, ""),
:body => File.read(attachment.diskfile),
:disposition => 'attachment; filename=' + attachment.filename + ';',
:headers => { 'Content-Id' => attachment.filename },
:transfer_encoding => 'base64'
end
end
end
def reminder(user, issues, days)
......
# https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
def render_multipart(method_name, body)
content_type "multipart/alternative"
if Setting.plain_text_mail?
content_type "text/plain"
body render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
part :content_type => "text/plain", :body => render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
else
content_type "multipart/alternative"
part :content_type => "text/plain", :body => render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
part :content_type => "text/html", :body => render_message("#{method_name}.text.html.rhtml", body)
end
(1-1/6)