Skip to content

1341 not receiving emails#1349

Merged
aharwood2 merged 7 commits into
devfrom
1341-not-receiving-emails
Jun 9, 2026
Merged

1341 not receiving emails#1349
aharwood2 merged 7 commits into
devfrom
1341-not-receiving-emails

Conversation

@aharwood2

Copy link
Copy Markdown
Member

This pull request refactors the email sending logic in EmailService.cs to simplify the SendEmail method and ensure that emails are sent individually to each recipient rather than as a group. The changes also introduce a delay between sending emails to different recipients and update logging for better clarity.

Email sending logic refactor:

  • Changed SendEmail to accept a single recipient (string to) instead of a list, and updated its implementation to add only one recipient per email. Logging statements were also updated accordingly. [1] [2] [3]

  • Updated all usages of SendEmail that previously passed a list of recipients to instead loop through each recipient and send emails individually, adding a 1-second delay between each send. [1] [2] [3]

Async improvements:

  • Changed background email sending tasks to use async/await for better asynchronous handling.

@aharwood2 aharwood2 linked an issue May 28, 2026 that may be closed by this pull request
@aharwood2 aharwood2 self-assigned this May 28, 2026
@aharwood2 aharwood2 added this to the v1.14.1 milestone May 28, 2026

@PhilBradbury PhilBradbury 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.

Not sure the creation of an SMTP client for each email is particularly efficient (can it be wrapped in a Using statement, or is a fresh one each time to minimise issues?) but for the amount we're sending I guess it should be fine.

However, I did notice this whilst reviewing the code:

Image

... which strikes me as being very manchester specific! Do we do that in case we don't have a registered email and we know that will work? I assume we'll have to remove it, but not sure what the backup will be.

@aharwood2

aharwood2 commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

Not sure the creation of an SMTP client for each email is particularly efficient (can it be wrapped in a Using statement, or is a fresh one each time to minimise issues?) but for the amount we're sending I guess it should be fine.

However, I did notice this whilst reviewing the code:

Image ... which strikes me as being very manchester specific! Do we do that in case we don't have a registered email and we know that will work? I assume we'll have to remove it, but not sure what the backup will be.

Agreed. Will add a setting for "email domain" or something and then a setting to use "backup email logic" or something? Or do we just do this away altogether and say if there isn't an email in the system then they just don't get emails?

@aharwood2 aharwood2 modified the milestones: v1.14.1, v1.14.0.1 Jun 8, 2026
@PhilBradbury

Copy link
Copy Markdown
Contributor

Agreed. Will add a setting for "email domain" or something and then a setting to use "backup email logic" or something? Or do we just do this away altogether and say if there isn't an email in the system then they just don't get emails?

Removing it altogether seems reasonable, IMO

…none already registered. If no email then don't send anything.
@PhilBradbury

Copy link
Copy Markdown
Contributor

@aharwood2 - removed the creation of the email using username@manchester.ac.uk. Also added a quick check to build and only send email if there is an address now.

Copilot AI 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.

Pull request overview

This pull request updates EmailService to send emails per-recipient (instead of batching recipients into a single message), adds a delay between sends, and adjusts async usage for background email notification flows.

Changes:

  • Refactors SendEmail to accept a single recipient (string to) and builds each MailMessage with one To address.
  • Updates notification flows to loop over recipients and send emails individually with a 1-second delay between sends.
  • Converts some Task.Run(...) usages to Task.Run(async () => ...) to support await Task.Delay(...) in those loops.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PPMTool/Services/EmailService.cs
Comment thread PPMTool/Services/EmailService.cs Outdated
Comment thread PPMTool/Services/EmailService.cs Outdated
Comment thread PPMTool/Services/EmailService.cs Outdated
PhilBradbury
PhilBradbury previously approved these changes Jun 9, 2026

@PhilBradbury PhilBradbury 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.

Untested, but looks logical to me.

@aharwood2 aharwood2 requested a review from gdonval as a code owner June 9, 2026 11:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
aharwood2 and others added 3 commits June 9, 2026 12:07
Logging fix

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Logging fix

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@aharwood2 aharwood2 merged commit 7755ab2 into dev Jun 9, 2026
11 checks passed
@aharwood2 aharwood2 deleted the 1341-not-receiving-emails branch June 9, 2026 11:16
@aharwood2 aharwood2 modified the milestones: v1.14.0.1, v1.14.1 Jun 15, 2026
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.

Not receiving emails

3 participants