Skip to content
Snippets Groups Projects
Commit 31f34852 authored by André Lahmann's avatar André Lahmann
Browse files

* allow securing connection to mailserver either via explicit setting in...

* allow securing connection to mailserver either via explicit setting in config.ini or by configured mailserver port
parent 745f0051
No related merge requests found
......@@ -388,6 +388,10 @@ host = localhost
port = 25
;username = user
;password = pass
; If a login is required you can define which protocol to use for securing the
; connection. If no explicit protocol ('tls' or 'ssl') is configured, a protocol
; based on the configured port is chosen (587 -> tls, 487 -> ssl).
;secure = tls
; If set to false, users can send anonymous emails; otherwise, they must log in first
require_login = true
; Should we put the logged-in user's address in the "from" field by default?
......
......@@ -64,6 +64,17 @@ class Factory implements \Zend\ServiceManager\FactoryInterface
'username' => $config->Mail->username,
'password' => $config->Mail->password
];
if (isset($config->Mail->secure)) {
// always set user defined secure connection
$settings['connection_config']['ssl'] = $config->Mail->secure;
} else {
// set default secure connection based on configured port
if ($settings['port'] == '587') {
$settings['connection_config']['ssl'] = 'tls';
} elseif ($settings['port'] == '487') {
$settings['connection_config']['ssl'] = 'ssl';
}
}
}
$transport = new Smtp();
$transport->setOptions(new SmtpOptions($settings));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment