Skip to content

Add 'Email All' feature for users#306

Draft
cmyers-mieweb wants to merge 1 commit into
mainfrom
cmyers_issue305
Draft

Add 'Email All' feature for users#306
cmyers-mieweb wants to merge 1 commit into
mainfrom
cmyers_issue305

Conversation

@cmyers-mieweb
Copy link
Copy Markdown
Collaborator

@cmyers-mieweb cmyers-mieweb commented May 13, 2026

issue: #305
Add UI, route, and email utility to send a message to all users with an email address. Changes include:

  • routers/users.js: import sendBulkEmail and add POST /users/email-all which validates subject/message, checks SMTP configuration, collects unique non-empty user emails, calls sendBulkEmail, and sets flash messages for success/partial/failure cases with error logging.
  • utils/email.js: add sendBulkEmail (sends one message per recipient using configured noreply address), escapeHtml helper to sanitize HTML body, and export sendBulkEmail.
  • views/users/index.ejs: add "Email All" button and modal form to compose subject and message, showing recipient count and confirming send.

Includes basic input validation, SMTP existence check, per-recipient send reporting, and HTML-escaping of message content.
image

Add UI, route, and email utility to send a message to all users with an email address. Changes include:

- routers/users.js: import sendBulkEmail and add POST /users/email-all which validates subject/message, checks SMTP configuration, collects unique non-empty user emails, calls sendBulkEmail, and sets flash messages for success/partial/failure cases with error logging.
- utils/email.js: add sendBulkEmail (sends one message per recipient using configured noreply address), escapeHtml helper to sanitize HTML body, and export sendBulkEmail.
- views/users/index.ejs: add "Email All" button and modal form to compose subject and message, showing recipient count and confirming send.

Includes basic input validation, SMTP existence check, per-recipient send reporting, and HTML-escaping of message content.
@cmyers-mieweb cmyers-mieweb requested a review from runleveldev May 13, 2026 15:31
Comment on lines +178 to +179
const settings = await Setting.getMultiple(['smtp_noreply_address']);
const from = settings.smtp_noreply_address || 'noreply@localhost';
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.

I don't like this fallback. If smtp_noreply_address is not set this should throw up instead.

Comment on lines +198 to +211
for (const to of recipients) {
try {
await transporter.sendMail({
from,
to,
subject,
text: message,
html
});
sent.push(to);
} catch (error) {
failed.push({ to, error: error.message });
}
}
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.

Can we do a single email with BCC instead of looping?

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