forked from remp2020/remp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmtpMailer.php
63 lines (54 loc) · 1.63 KB
/
SmtpMailer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Remp\MailerModule\Mailer;
use Nette\Mail\IMailer;
use Nette\Mail\Message;
use Remp\MailerModule\Config\Config;
use Remp\MailerModule\Repository\ConfigsRepository;
class SmtpMailer extends Mailer implements IMailer
{
private $mailer;
protected $alias = 'remp-smtp';
protected $options = [
'host' => [
'required' => true,
'label' => 'SMTP host',
'description' => 'IP address or hostname of SMTP server (e.g. 127.0.0.1)',
],
'port' => [
'required' => true,
'label' => 'SMTP Port',
'description' => 'Port on which your SMTP server is exposed (e.g. 1025)',
],
'username' => [
'required' => false,
'label' => 'SMTP Username',
],
'password' => [
'required' => false,
'label' => 'SMTP Password',
],
'secure' => [
'required' => false,
'label' => 'SMTP Secure',
'description' => 'Secure protocol used to connect (e.g. ssl)',
],
];
public function __construct(
Config $config,
ConfigsRepository $configsRepository
) {
parent::__construct($config, $configsRepository);
// SMTP Mailer expects plain options
$options = [];
foreach ($this->options as $name => $option) {
if (isset($option['value'])) {
$options[$name] = $option['value'];
}
}
$this->mailer = new \Nette\Mail\SmtpMailer($options);
}
public function send(Message $message)
{
$this->mailer->send($message);
}
}