Skip to content

ability to email a group - #1

Draft
chishiki wants to merge 1 commit into
11.0.xfrom
node-group-email-spike-groups
Draft

ability to email a group#1
chishiki wants to merge 1 commit into
11.0.xfrom
node-group-email-spike-groups

Conversation

@chishiki

Copy link
Copy Markdown
Member

Summary

Adds a reusable way to send one email to every member of a UW NetID group, the foundational building block for any future feature that needs to notify a group (e.g. a stale-content digest). This PR is just the mailer itself, not any specific notification.

  • NetIDGroups::getGroupMemberEmails() maps a group's member NetIDs to netid@uw.edu, UW's standard forwarding address, rather than sending to the group's own email alias (which may not exist, may not match the Group ID, and requires separate "authorized senders" configuration in groups.uw.edu we can't verify from Drupal).
  • GroupMailer::sendToGroup($group, $subject, $body) refuses to send to any group not in uw_groups.settings:active_groups, logging the refusal instead of failing silently. That allow-list is the only set of groups the LTS service account is known to have membership-viewer access to; other UW Groups, especially Restricted/Confidential institutional ones, may reject or silently empty-out membership queries from these credentials.
  • Sends one email per member rather than a single multi-recipient message, since group rosters can be privacy-sensitive, and this avoids exposing "who's a member" via a shared To/Bcc field.
  • Returns {sent, failed, error} instead of throwing, so a future caller (e.g. cron code) can decide how to react to a membership-fetch failure or a partial send failure, rather than the mailer making that call unilaterally.
  • hook_mail()'s group-notice key takes subject/body from params rather than hardcoding copy, mirroring the pattern in moderation_emails.module but generalized so it isn't coupled to one notification's wording.

Testing

  • drush php:eval "print_r(\Drupal::service('uw_groups.group_mailer')->sendToGroup('<a real active group>', 'Test subject', 'Test body'));" against an environment with the LTS mTLS credentials configured
  • Confirm delivery via the target environment's mailsystem/phpmailer_smtp backend
  • Confirm a group not in the active-groups list returns error: group_not_active and sends nothing

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.

1 participant