Matomo uses a copy of Zend Mail that has last been updated in 2011 (in https://github.com/matomo-org/matomo/issues/2581)
While SMTP isn't the fastest developing protocol, a lot has changed in that time.
So instead of keeping an outdated library or reinventing the wheel, I'd recommend replacing it with a maintained, popular PHP library like PHPmailer or swiftmailer.
Bonus side effect: We would get proper error messages for hard to debug errors instead of things like
fwrite(): send of 6 bytes failed with errno=32 Broken pipe.