1341 not receiving emails#1349
Conversation
PhilBradbury
left a comment
There was a problem hiding this comment.
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:
... 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.
Removing it altogether seems reasonable, IMO |
…none already registered. If no email then don't send anything.
|
@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. |
There was a problem hiding this comment.
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
SendEmailto accept a single recipient (string to) and builds eachMailMessagewith oneToaddress. - Updates notification flows to loop over recipients and send emails individually with a 1-second delay between sends.
- Converts some
Task.Run(...)usages toTask.Run(async () => ...)to supportawait Task.Delay(...)in those loops.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PhilBradbury
left a comment
There was a problem hiding this comment.
Untested, but looks logical to me.
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>
Logging fix Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

This pull request refactors the email sending logic in
EmailService.csto simplify theSendEmailmethod 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
SendEmailto 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
SendEmailthat 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:
async/awaitfor better asynchronous handling.