osTicket Version v1.17-rc3 (34c64f1)
Web Server Software: LiteSpeed
MySQL Version: 10.3.35
PHP Version: 8.0.21
Oauth2 Client v.0.2
- Self-hosted on a shared cPanel web host. (https://osticket.domain.com)
- Domain DNS is managed in cPanel but we forward our MX to O365 tenant. (O365 Domain health check is green)
- OAuth plugin was configured according to docs with no errors.

Issue: Sporadic email delivery failures. I've sent emails to two O365 tenants including ours and it works every time. I have a work Gmail that just would not receive email from osTicket. Thought it was SPF records or something with Gmail blocking until I tested with my personal Gmail and it worked every time I tested. So it's not Gmail specifically and regarding the address, I have the most issues with it's not marked as spam or anything.
I just now looked at the osTicket logs and it's why I'm writing here. I noticed that with emails the system tries to send out I get a pair of error messages in the logs for each send attempt. These errors happen but then prior to and right after certain emails make it out fine.
Mailer Error
Unable to email via php mail function Invalid header value detected
Log Date: Tuesday, 16 August 2022 at 14:10 IP Address: XXX.XXX.XXX.XXX
Mailer Error
Unable to email via SMTP: sub@domain.com (smtp.office365.com:587) Invalid header value detected
Log Date: Tuesday, 16 August 2022 at 14:10 IP Address: XXX.XXX.XXX.XXX
Is there anything else I can provide to glean more about what is going on here? Is it possible the OAuth isn't quite working despite the lack of errors or warnings?
Regards,
Matt