|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Loggers\SwiftMailer\SendmailTransportMailerFactory |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Loggers\SwiftMailer; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\SwiftMailerKeys; |
|
24
|
|
|
use TechDivision\Import\Configuration\SwiftMailer\TransportConfigurationInterface; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Factory implementation for a swift mailer with a simple sendmail transport. |
|
28
|
|
|
* |
|
29
|
|
|
* @author Tim Wagner <[email protected]> |
|
30
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
32
|
|
|
* @link https://github.com/techdivision/import |
|
33
|
|
|
* @link http://www.techdivision.com |
|
34
|
|
|
*/ |
|
35
|
|
|
class SendmailTransportMailerFactory implements TransportMailerFactoryInterface |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Creates a new swift mailer instance based on the passed transport configuration. |
|
40
|
|
|
* |
|
41
|
|
|
* @param \TechDivision\Import\Configuration\SwiftMailer\TransportConfigurationInterface $transportConfiguration The mailer configuration |
|
42
|
|
|
* |
|
43
|
|
|
* @return \Swift_Mailer The mailer instance |
|
44
|
|
|
*/ |
|
45
|
|
|
public function factory(TransportConfigurationInterface $transportConfiguration) |
|
46
|
|
|
{ |
|
47
|
|
|
|
|
48
|
|
|
// initialize and load the sendmail command parameter |
|
49
|
|
|
$command = '/usr/sbin/sendmail -bs'; |
|
50
|
|
|
if ($transportConfiguration->hasParam(SwiftMailerKeys::COMMAND)) { |
|
51
|
|
|
$command = $transportConfiguration->getParam(SwiftMailerKeys::COMMAND); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
// initialize and create the mailer transport instance |
|
55
|
|
|
$transport = \Swift_SendmailTransport::newInstance($command); |
|
56
|
|
|
|
|
57
|
|
|
// initialize, create and return the swift mailer instance |
|
58
|
|
|
return \Swift_Mailer::newInstance($transport); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|