diff options
author | Jaap van der Plas <jvdplas@gmail.com> | 2019-02-13 15:55:38 +0100 |
---|---|---|
committer | George Claghorn <george.claghorn@gmail.com> | 2019-02-13 09:55:38 -0500 |
commit | 2488901da8a4d896003254869a378f0c1b4ed3f2 (patch) | |
tree | 6911e103fef3a6e87f9274b3f8bde75417c232a6 /actionmailer/lib | |
parent | 47e3bbeb9057b37c244330cc4e745c8a8090e8c5 (diff) | |
download | rails-2488901da8a4d896003254869a378f0c1b4ed3f2.tar.gz rails-2488901da8a4d896003254869a378f0c1b4ed3f2.tar.bz2 rails-2488901da8a4d896003254869a378f0c1b4ed3f2.zip |
Don’t log recipients when sending mail
Since production applications typically run with log level info and
email adresses should be considered as sensitive data we want to prevent
them from ending up in the logs. In development mode (with log level
debug) they are still logged as part of the Mail::Message object.
Diffstat (limited to 'actionmailer/lib')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/log_subscriber.rb | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 5610212fad..033a7f5b9e 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -593,6 +593,7 @@ module ActionMailer private def set_payload_for_mail(payload, mail) + payload[:mail] = mail.encoded payload[:mailer] = name payload[:message_id] = mail.message_id payload[:subject] = mail.subject @@ -601,7 +602,6 @@ module ActionMailer payload[:bcc] = mail.bcc if mail.bcc.present? payload[:cc] = mail.cc if mail.cc.present? payload[:date] = mail.date - payload[:mail] = mail.encoded payload[:perform_deliveries] = mail.perform_deliveries end diff --git a/actionmailer/lib/action_mailer/log_subscriber.rb b/actionmailer/lib/action_mailer/log_subscriber.rb index 25c99342c2..26910f20f0 100644 --- a/actionmailer/lib/action_mailer/log_subscriber.rb +++ b/actionmailer/lib/action_mailer/log_subscriber.rb @@ -10,11 +10,10 @@ module ActionMailer def deliver(event) info do perform_deliveries = event.payload[:perform_deliveries] - recipients = Array(event.payload[:to]).join(", ") if perform_deliveries - "Sent mail to #{recipients} (#{event.duration.round(1)}ms)" + "Delivered mail #{event.payload[:message_id]} (#{event.duration.round(1)}ms)" else - "Skipped sending mail to #{recipients} as `perform_deliveries` is false" + "Skipped delivery of mail #{event.payload[:message_id]} as `perform_deliveries` is false" end end |