Skip to content

Add reply_to support to DeliveryMethod#12

Merged
benedikt merged 1 commit intouserlist:mainfrom
benjaminhouy:main
Oct 16, 2025
Merged

Add reply_to support to DeliveryMethod#12
benedikt merged 1 commit intouserlist:mainfrom
benjaminhouy:main

Conversation

@benjaminhouy
Copy link
Copy Markdown
Contributor

Summary

This PR adds support for the reply_to email header in the DeliveryMethod class. The Userlist Push API already supports the reply_to parameter, but the gem's DeliveryMethod wasn't serializing it from ActionMailer Mail objects.

Changes

  1. Added reply_to serialization - The serialize method now includes reply_to: serialize_address(mail.reply_to)
  2. Updated serialize_address method - Modified to return nil for empty/nil addresses instead of empty arrays, ensuring .compact works correctly
  3. Added comprehensive tests - Two new test contexts verify:
    • reply_to is properly serialized when present
    • reply_to is omitted from payload when not present (via .compact)

Backward Compatibility

This change is fully backward compatible:

  • Uses existing serialize_address method for consistency with to/from handling
  • Relies on .compact to omit reply_to when not set
  • All existing tests pass (212 examples, 0 failures)

Use Case

This enables contact forms and other transactional emails to specify a custom reply-to address, allowing recipients to reply directly to the original sender rather than the system email address.

Example usage:

mail(
  to: 'support@example.com',
  from: 'noreply@example.com',
  reply_to: 'user@example.com',  # Now properly sent to Userlist API
  subject: 'Contact Form Submission'
)

Testing

All 212 existing tests pass, plus 2 new tests specifically for reply_to functionality.

The Userlist Push API supports the reply_to parameter for messages,
but the DeliveryMethod class wasn't serializing it from ActionMailer
Mail objects.

This commit:
- Adds reply_to to the serialize method
- Updates serialize_address to return nil for empty addresses
- Adds comprehensive tests for both presence and absence of reply_to
- Maintains backward compatibility via .compact

All existing tests pass (212 examples, 0 failures).
@benedikt benedikt merged commit f999c4f into userlist:main Oct 16, 2025
@benedikt
Copy link
Copy Markdown
Contributor

Thank you, @benjaminhouy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants