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

refs #5423:

* added support for mailserver connection encryption
parent 0cb0288e
No related merge requests found
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
namespace finc\Module\Configuration; namespace finc\Module\Configuration;
$config = [ $config = [
'service_manager' => [
'factories' => [
'VuFind\Mailer' => 'finc\Mailer\Factory'
]
],
'controllers' => [ 'controllers' => [
'invokables' => [ 'invokables' => [
'my-research' => 'finc\Controller\MyResearchController', 'my-research' => 'finc\Controller\MyResearchController',
...@@ -9,6 +14,11 @@ $config = [ ...@@ -9,6 +14,11 @@ $config = [
], ],
'vufind' => [ 'vufind' => [
'plugin_managers' => [ 'plugin_managers' => [
'auth' => [
'invokables' => [
'shibboleth' => 'finc\Auth\Shibboleth',
],
],
'ils_driver' => [ 'ils_driver' => [
'factories' => [ 'factories' => [
'fincils' => 'finc\ILS\Driver\Factory::getFincILS', 'fincils' => 'finc\ILS\Driver\Factory::getFincILS',
......
<?php
/**
* Factory for instantiating Mailer objects
*
* PHP version 5
*
* Copyright (C) Villanova University 2009.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Mailer
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
namespace finc\Mailer;
use Zend\Mail\Transport\Smtp, Zend\Mail\Transport\SmtpOptions;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Factory for instantiating Mailer objects
*
* @category VuFind2
* @package Mailer
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*
* @codeCoverageIgnore
*/
class Factory implements \Zend\ServiceManager\FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $sm Service manager
*
* @return mixed
*/
public function createService(ServiceLocatorInterface $sm)
{
// Load configurations:
$config = $sm->get('VuFind\Config')->get('config');
// Create mail transport:
$settings = [
'host' => $config->Mail->host, 'port' => $config->Mail->port
];
if (isset($config->Mail->username) && isset($config->Mail->password)) {
$settings['connection_class'] = 'login';
$settings['connection_config'] = [
'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));
// Create service:
return new \VuFind\Mailer\Mailer($transport);
}
}
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