Skip to content
Snippets Groups Projects

Prevents Mail::SMTP monkey patch from overriding defaults

Merged Marc Saleiko requested to merge ms-fix-mail-smtp-defaults-override into master

What does this MR do and why?

Solves Mail::SMTP monkey patch overrides defaults (#423268 - closed)

Corrective action for incident 2023-08-23: accidentally sent out emails to som... (gitlab-com/gl-infra/production#16223 - closed)

Contributes to Configurable e-mail address for service desk (#329990 - closed)

Prevents Mail::SMTP monkey patch from overriding defaults

When changing the delivery method settings of a Mail::Message the monkey patch constructor would override the defaults of Mail::SMTP with the configured settings. Now we ensure we use fresh defaults for every new delivery method settings.

How to set up and validate locally

On master run the following in your rails console:

# What are the defaults?
Mail.delivery_method
# Create a new email and override the delivery method here
m = Mail.new
# This should only be valid for this message
m.delivery_method Mail::SMTP, {user_name: 'some_username'}
# But defaults are now based in the input above
Mail.delivery_method

Now switch to this branch and run the following snippet:

# What are the defaults again?
Mail.delivery_method
# Create a new email and override the delivery method here
m = Mail.new
# Again override just for this message
m.delivery_method Mail::SMTP, {user_name: 'some_username'}
# Defaults should be untouched and equal the very first dump
Mail.delivery_method

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Marc Saleiko

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading