If you are using a self-signed certificate for your mailing server - in our case inside intranet - and setup moodle to use that smtp server for emails, it'll fail with the following message:
lib/moodlelib.php email_to_user(): SMTP connect() failed
This happens with PHP 5.6 and newer, the details can be read here https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Proper certificates are a useful protection, inside intranets self-signed certificates should be enough though.
My current workaround looks like this, added in line 5429 inside lib/moodlelib.php before return $mailer;
In my opinion, there should be a setting inside config.php for this and it should be included into core.