Skip to content

The ClientPaymentMailer#payment method throws a Postmark::InvalidEmai…#2063

Open
amolmjoshi93 wants to merge 1 commit intodevelopfrom
2062-the-clientpaymentmailerpayment-method-throws-a-postmarkinvalidemailrequesterror-zero-recipients-specified-error-when-attempting-to-send-a-payment-confirmation-email-to-a-client-that-has-no-email-address-configured
Open

The ClientPaymentMailer#payment method throws a Postmark::InvalidEmai…#2063
amolmjoshi93 wants to merge 1 commit intodevelopfrom
2062-the-clientpaymentmailerpayment-method-throws-a-postmarkinvalidemailrequesterror-zero-recipients-specified-error-when-attempting-to-send-a-payment-confirmation-email-to-a-client-that-has-no-email-address-configured

Conversation

@amolmjoshi93
Copy link
Contributor

@amolmjoshi93 amolmjoshi93 commented Feb 9, 2026

…lRequestError: Zero recipients specified error when attempting to send a payment confirmation email to a client that has no email address configured.

Closes #2062

Summary by CodeRabbit

  • Bug Fixes

    • Improved payment email delivery by adding validation to prevent sending emails when a client email address is missing.
  • Tests

    • Added comprehensive test coverage for payment email scenarios when client contact information is unavailable.

…lRequestError: Zero recipients specified error when attempting to send a payment confirmation email to a client that has no email address configured.
@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

The change adds email address validation to the ClientPaymentMailer's can_send_mail? method, preventing attempts to send payment confirmation emails when clients lack email addresses. One line is modified in production code and two test cases are added to cover this edge case.

Changes

Cohort / File(s) Summary
Email validation in mailer
app/mailers/client_payment_mailer.rb
Updated can_send_mail? to verify both that client_payment_sent_at is nil AND that client.email is present before sending mail.
Test coverage for no-email scenario
spec/mailers/client_payment_mailer_spec.rb
Added new context block with tests asserting that mail delivery is skipped (returns NullMail) and client_payment_sent_at remains unmodified when client has no email address.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A guardian guard clause hops into place,
Checking for emails in the client's face,
No address? No problem! We gracefully stay,
Postmark won't frown on our thoughtful new way. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is truncated and incomplete, making it impossible to understand the actual change. It should state the complete solution rather than just the problem. Update the title to be complete and descriptive of the fix, such as 'Add email presence check to ClientPaymentMailer#can_send_mail?'
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The code changes fully implement the proposed solution in issue #2062 by updating can_send_mail? to check both client_payment_sent_at and email presence, with comprehensive test coverage for the no-email scenario.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the issue: the mailer guard clause is updated to check email presence, and tests verify the fix handles the no-email case correctly.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2062-the-clientpaymentmailerpayment-method-throws-a-postmarkinvalidemailrequesterror-zero-recipients-specified-error-when-attempting-to-send-a-payment-confirmation-email-to-a-client-that-has-no-email-address-configured

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

2 participants