mirror of
https://github.com/rickbarrette/redmine_qbo_reminders.git
synced 2026-11-17 21:00:36 -05:00
Send reminders even when Redmine's email delivery is off
Redmine sets perform_deliveries = false for every mailer when it has no email settings of its own, so reminders were skipped (and recorded as sent) without ever reaching the SMTP server. Messages sent through the plugin's own SMTP server now always go out; with Redmine's email settings, a reminder fails with a clear error instead of being dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
2 files changed
+16
-2
No files matched your search
@@ -26,11 +26,25 @@ class AppointmentReminderMailer < ActionMailer::Base
|
||||
# A Message-ID on the sending domain, rather than the server's host name
|
||||
headers['Message-ID'] = "<reminder.#{Time.now.to_i}.#{SecureRandom.hex(6)}@#{settings.mail_domain}>"
|
||||
|
||||
delivery = settings.delivery_options
|
||||
# Through Redmine's own settings, Redmine decides whether mail goes out at all; say so rather than
|
||||
# quietly dropping the reminder
|
||||
if delivery.empty? && !ActionMailer::Base.perform_deliveries
|
||||
raise DeliveryOff, "Redmine's email delivery is turned off (config/configuration.yml); choose \"This SMTP server\" in the reminder settings"
|
||||
end
|
||||
|
||||
options = { to: email, from: settings.from, subject: message.subject }
|
||||
options[:reply_to] = settings.reply_to if settings.reply_to
|
||||
mail(options.merge(settings.delivery_options)) do |format|
|
||||
mail(options.merge(delivery)) do |format|
|
||||
format.text { render plain: message.text }
|
||||
format.html { render html: message.html.html_safe }
|
||||
end
|
||||
# Redmine turns delivery off for every mailer when it has no email settings of its own (and in some
|
||||
# environments); reminders sent through the plugin's own SMTP server go out regardless
|
||||
message_obj = self.message
|
||||
message_obj.perform_deliveries = true unless delivery.empty?
|
||||
message_obj
|
||||
end
|
||||
|
||||
class DeliveryOff < StandardError; end
|
||||
end
|
||||
Reference in new issue
Block a user