mailgun-ruby icon indicating copy to clipboard operation
mailgun-ruby copied to clipboard

BatchMessage modifies stored test deliveries

Open nivla opened this issue 11 months ago • 0 comments

Description

When using Mailgun::Client in test mode with batch messages, the reset_message method in BatchMessage modifies the original hash stored in Mailgun::Client.deliveries. This causes the stored test deliveries to lose their :to, :cc, :bcc and recipient-variables data after the batch is processed.

Steps to Reproduce

  1. Enable test mode on Mailgun client
  2. Create a batch message with recipients (to, cc, bcc)
  3. Send the message
  4. Check the stored delivery in Mailgun::Client.deliveries
  5. The stored hash is modified after reset_message is called

Code Example

client = Mailgun::Client.new('key')
client.enable_test_mode!
batch = Mailgun::BatchMessage.new(client, 'domain.com')
batch.add_recipient(:to, '[email protected]')
batch.add_recipient(:cc, '[email protected]')
batch.add_recipient(:bcc, '[email protected]')
batch.finalize

# At this point, checking `Mailgun::Client.deliveries` the to/cc/bcc/recipient-variables fields are gone

nivla avatar Feb 10 '25 21:02 nivla