It could be email, you might be on to something and it is probably worth checking out. During a low activity time, you might want to enable email debugging and perform an action that generates an email. See if there is anything interesting in the SMTP debug output.
I've had experience with folks using office365 in the past, but am not aware of any inherent performance issues with Moodle using it to send email.
If the problem is in fact delay on the SMTP connection to Office 365 mail servers, I wondered if maybe this mail service rate limits connections, or if some specific setting change might be needed on the 365 account. So I did some web searching:
- it seems you aren't the only one
Interesting concept... maybe your Moodle server isn't able to support TLS 1.1, see link:
- The idea on that link is that if your Moodle server can make TLS 1.1 smtp connections, that email sends more quickly. If your Moodle system cannot negotiate TLS 1.1, then there is a bunch more "negotiation" that slows it down.
- I don't know if this is a worthwhile rabbit hole or not, but knowing the OpenSSL version your PHP is built against on your Moodle server might be telling as to whether or not this theory might be true