diff --git a/config.inc.php b/config.inc.php index d1e76e18..98b00bfa 100644 --- a/config.inc.php +++ b/config.inc.php @@ -171,6 +171,9 @@ $CONF['smtp_port'] = '25'; // Used in the HELO when sending emails from Postfix Admin $CONF['smtp_client'] = ''; +// Set 'YES' to use TLS when sending emails. +$CONF['smtp_sendmail_tls'] = 'NO'; + // Encrypt // In what way do you want the passwords to be crypted? // md5crypt = internal postfix admin md5 diff --git a/functions.inc.php b/functions.inc.php index 3fbbee19..56eacbd2 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1398,6 +1398,16 @@ function smtp_mail($to, $from, $data, $password = "", $body = "") { return false; } else { smtp_get_response($fh); + + if (Config::bool('smtp_sendmail_tls')) { + fputs($fh, "STARTTLS\r\n"); + smtp_get_response($fh); + + stream_set_blocking ($fh, true); + stream_socket_enable_crypto($fh, true, STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); + stream_set_blocking ($fh, true); + } + fputs($fh, "EHLO $smtp_server\r\n"); smtp_get_response($fh);