Merge pull request #10687 from opf/fix/42377/mailer-interceptors
Fix mailer interceptors rejecting empty to addressespull/10690/head
commit
4557cb924d
@ -0,0 +1,17 @@ |
|||||||
|
module Interceptors |
||||||
|
class DefaultHeaders |
||||||
|
def self.delivering_email(mail) |
||||||
|
mail.headers(default_headers) |
||||||
|
end |
||||||
|
|
||||||
|
def self.default_headers |
||||||
|
{ |
||||||
|
'X-Mailer' => 'OpenProject', |
||||||
|
'X-OpenProject-Host' => Setting.host_name, |
||||||
|
'X-OpenProject-Site' => Setting.app_title, |
||||||
|
'Precedence' => 'bulk', |
||||||
|
'Auto-Submitted' => 'auto-generated' |
||||||
|
} |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,10 @@ |
|||||||
|
module Interceptors |
||||||
|
class DoNotSendMailsWithoutRecipient |
||||||
|
def self.delivering_email(mail) |
||||||
|
receivers = [mail.to, mail.cc, mail.bcc] |
||||||
|
# the above fields might be empty arrays (if entries have been removed |
||||||
|
# by another interceptor) or nil, therefore checking for blank? |
||||||
|
mail.perform_deliveries = false if receivers.all?(&:blank?) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue