Sending Email trough SMTP using self signed server certificate

Setup:
Freebsd 10 Jail with PHP 5.6, Aapche 2.4, Mysql 5.5.

Tryng to send Email using SMTP and my Email server running Zimbra, with self signed certicate, I found this error in log:

ERROR - 2017-01-10 22:26:18 --> Severity: Warning  --> stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed /usr/local/www/apache24/data/vendor/phpmailer/phpmailer/class.smtp.php 355

The error disappear and I can now send mail by adding

$mail->SMTPOptions = array(
'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
        )
);

in

application/modules/mailer/helpers/phpmailer_helper.php
just below the line

$mail->isHTML();

As a feature is it possible to add a checbox “accept self signed certificate from server” in mail configuration?

Last Update: 07.05.2017

I’m not against having such an option in IP. But if the server is facing the public internet, you could consider getting a free certificate from Let’s Encrypt.