Skip to content

fix multiple recipients in smtp plugin - #1732

Merged
jokob-sk merged 4 commits into
netalertx:mainfrom
etgocode:patch-1
Aug 8, 2026
Merged

fix multiple recipients in smtp plugin#1732
jokob-sk merged 4 commits into
netalertx:mainfrom
etgocode:patch-1

Conversation

@etgocode

@etgocode etgocode commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Problem

When using multiple email recipients in the smtp plugin separated by , as suggested in the documentation, no emails are sent because the addresses break in the sanitization step.
grafik

Fix

I moved the splitting of the addresses in front of the sanitization and modified the sanitization of the recipient adresses to iterate over the provided array.

Summary by CodeRabbit

  • New Features

    • Email reports can now be delivered to multiple configured recipients.
    • Valid recipient addresses are individually sanitized before delivery.
    • Reports are addressed consistently to all valid recipients.
  • Bug Fixes

    • Improved handling of comma-separated recipient lists.
    • Prevented invalid or malformed addresses from being used.
    • Reports are no longer sent when no valid recipients remain.

moved splitting of multiple recipient email adresses before sanitization because otherwise it breaks when sanitized.
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 541cba9f-47da-481b-a37b-13b6fa7a8c67

📥 Commits

Reviewing files that changed from the base of the PR and between 69de0dd and 9c36b6e.

📒 Files selected for processing (1)
  • front/plugins/_publisher_email/email_smtp.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • front/plugins/_publisher_email/email_smtp.py

📝 Walkthrough

Walkthrough

The SMTP publisher now parses SMTP_REPORT_TO into multiple recipients, removes empty entries, sanitizes each recipient, and uses the message’s To header for SMTP delivery.

Changes

SMTP recipient handling

Layer / File(s) Summary
Parse, sanitize, and deliver recipient list
front/plugins/_publisher_email/email_smtp.py
send parses and validates the recipient list. The sanitizer processes each recipient and returns the sanitized list. SMTP sendmail uses the message’s To header.

Sequence Diagram(s)

sequenceDiagram
  participant send
  participant sanitize_email_content
  participant SMTP
  send->>send: Parse and validate SMTP_REPORT_TO
  send->>sanitize_email_content: Pass recipient list
  sanitize_email_content-->>send: Return sanitized recipients
  send->>SMTP: Send message using To header
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing multiple-recipient SMTP delivery.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@front/plugins/_publisher_email/email_smtp.py`:
- Around line 122-125: Update the recipient loop around send_email() so each
iteration passes its current mail_addr as the SMTP envelope recipient instead of
the configured SMTP_REPORT_TO value. Modify both send_email() calls to use a
one-element recipient list containing mail_addr, while preserving the
per-recipient message headers.
- Around line 114-120: Update the recipient handling around to_emails to remove
empty tokens and reject invalid delimiter usage before sanitize_email_content().
Ensure send_email() passes the validated to_emails list, rather than the raw
SMTP_REPORT_TO value, as the recipients argument to smtplib.SMTP.sendmail().
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3014d611-1d13-441b-9230-460a2ab8dab4

📥 Commits

Reviewing files that changed from the base of the PR and between 4e6110a and 38bf120.

📒 Files selected for processing (1)
  • front/plugins/_publisher_email/email_smtp.py

Comment thread front/plugins/_publisher_email/email_smtp.py
Comment thread front/plugins/_publisher_email/email_smtp.py

@jokob-sk jokob-sk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per comments

`smtp_connection.sendmail()` now gets passed the correct recipient. Since `send_email()` is called once for every recipient the correct recipient can be retrieved from `msg` and no additional parameter needs to be passed.
- Resolves netalertx#1732 (comment)
@etgocode

etgocode commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@jokob-sk as far as I understand it both coderabbit comments are about the same issue and should be fixed by 72a0b09. Please let me know if I am missing something.

removed empty entries in `to_emails` caused i.e. by the input `,` as pointed out in netalertx#1732 (comment) 
Also added an abort if no entries remain in `to_emails` after this step.
@etgocode

etgocode commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@jokob-sk the remaining issues pointed out by the ai have been resolved.

@jokob-sk

jokob-sk commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

thanks a lot @etgocode

@jokob-sk
jokob-sk merged commit 9b47fb8 into netalertx:main Aug 8, 2026
6 checks passed
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