Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ rake helpdesk:localdb:stop
* [Orchitech Solutions](https://github.com/orchitech) - Added support for non-anonymous supportclients (sponsored by ISIC Global Office)
* [Orchitech Solutions](https://github.com/orchitech) - Added support for customizable email footers (sponsored by ISIC Global Office)
* [Orchitech Solutions](https://github.com/orchitech) - Added support for tracking email details (sponsored by ISIC Global Office)
* [Orchitech Solutions](https://github.com/orchitech) - Added support for sending HTML emails (sponsored by ISIC Global Office)

## License

Expand Down
9 changes: 9 additions & 0 deletions app/views/helpdesk_mailer/email_to_supportclient.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<%= Redmine::WikiFormatting.to_html(Setting.text_formatting, @body).html_safe %>
</body>
</html>
1 change: 1 addition & 0 deletions app/views/helpdesk_mailer/email_to_supportclient.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= @body %>
15 changes: 15 additions & 0 deletions db/migrate/008_create_custom_field_for_send_html_emails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class CreateCustomFieldForSendHtmlEmails < ActiveRecord::Migration
def self.up
c = CustomField.new(
:name => 'helpdesk-send-html-emails',
:editable => true,
:visible => false, # do not show it on the project summary page
:field_format => 'bool')
c.type = 'ProjectCustomField' # cannot be set by mass assignement!
c.save
end

def self.down
CustomField.find_by_name('helpdesk-send-html-emails').delete
end
end
5 changes: 4 additions & 1 deletion lib/helpdesk_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ def email_to_supportclient(issue, recipient, journal=nil, text='')
# available then use this one instead of the regular
r = CustomField.find_by_name('helpdesk-first-reply')
f = CustomField.find_by_name('helpdesk-email-footer')
h = CustomField.find_by_name('helpdesk-send-html-emails')
reply = p.nil? || r.nil? ? '' : p.custom_value_for(r).try(:value)
footer = p.nil? || f.nil? ? '' : p.custom_value_for(f).try(:value)
send_html_emails = p.nil? || h.nil? || p.custom_value_for(h).nil? ? false : p.custom_value_for(h).true?
# add any attachements
if journal.present? && text.present?
journal.details.each do |d|
Expand All @@ -58,12 +60,13 @@ def email_to_supportclient(issue, recipient, journal=nil, text='')
# sending out the journal note to the support client
# or the first reply message
t = text.present? ? "#{text}\n\n#{footer}" : reply
@body = expand_macros(t, issue, journal)
mail(
:from => sender.present? && sender || Setting.mail_from,
:reply_to => sender.present? && sender || Setting.mail_from,
:to => recipient,
:subject => subject,
:body => expand_macros(t, issue, journal),
:body => send_html_emails ? nil : @body,
:date => Time.zone.now
)
else
Expand Down