From 1e40bb9c09acfcb5dcd9d4ed6c5450c1dbca4d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 25 Jun 2024 08:45:26 +0200 Subject: [PATCH] Send email to address in custom field? #340 --- app/models/custom_workflow_mailer.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/custom_workflow_mailer.rb b/app/models/custom_workflow_mailer.rb index 3562a66..899d039 100644 --- a/app/models/custom_workflow_mailer.rb +++ b/app/models/custom_workflow_mailer.rb @@ -25,15 +25,15 @@ class CustomWorkflowMailer < Mailer layout 'mailer' def self.deliver_custom_email(user, headers = {}) - custom_email(user, headers).deliver_later + custom_email(user, headers, headers.dup).deliver_later end - def custom_email(user, headers) - headers[:to] = user.mail if user - text_body = headers.delete :text_body - html_body = headers.delete :html_body - template_name = headers.delete :template_name - template_params = headers.delete(:template_params) || {} + def custom_email(user, headers, cw_headers) + headers[:to] ||= user.mail + text_body = cw_headers[:text_body] + html_body = cw_headers[:html_body] + template_name = cw_headers[:template_name] + template_params = cw_headers[:template_params] || {} if text_body || html_body mail headers do |format| format.text { render plain: text_body } if text_body.present?