|
1
|
|
|
<?php namespace Anomaly\Streams\Platform; |
|
2
|
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Mail\Mailer; |
|
4
|
|
|
use Illuminate\Support\ServiceProvider; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class StreamsMailProvider |
|
8
|
|
|
* |
|
9
|
|
|
* @link http://pyrocms.com/ |
|
10
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
|
11
|
|
|
* @author Ryan Thompson <[email protected]> |
|
12
|
|
|
* @package Anomaly\Streams\Platform |
|
13
|
|
|
*/ |
|
14
|
|
|
class StreamsMailProvider extends ServiceProvider |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Register the service provider. |
|
19
|
|
|
* |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
public function register() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->app->singleton( |
|
25
|
|
|
'mailer', |
|
26
|
|
|
function () { |
|
27
|
|
|
|
|
28
|
|
|
$mailer = new Mailer( |
|
29
|
|
|
$this->app['view'], $this->app['swift.mailer'], $this->app['events'] |
|
30
|
|
|
); |
|
31
|
|
|
|
|
32
|
|
|
$mailer->setContainer($this->app); |
|
33
|
|
|
|
|
34
|
|
|
if ($this->app->bound('Psr\Log\LoggerInterface')) { |
|
35
|
|
|
$mailer->setLogger($this->app->make('Psr\Log\LoggerInterface')); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
if ($this->app->bound('queue')) { |
|
39
|
|
|
$mailer->setQueue($this->app['queue.connection']); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$from = $this->app['config']['mail.from']; |
|
43
|
|
|
|
|
44
|
|
|
if (is_array($from) && isset($from['address'])) { |
|
45
|
|
|
$mailer->alwaysFrom($from['address'], $from['name']); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$to = $this->app['config']['mail.to']; |
|
49
|
|
|
|
|
50
|
|
|
if (is_array($to) && isset($to['address'])) { |
|
51
|
|
|
$mailer->alwaysTo($to['address'], $to['name']); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$pretend = $this->app['config']->get('mail.pretend', false); |
|
55
|
|
|
|
|
56
|
|
|
$mailer->pretend($pretend); |
|
57
|
|
|
|
|
58
|
|
|
return $mailer; |
|
59
|
|
|
} |
|
60
|
|
|
); |
|
61
|
|
|
|
|
62
|
|
|
$this->app->singleton( |
|
63
|
|
|
'Illuminate\Mail\Mailer', |
|
64
|
|
|
function () { |
|
65
|
|
|
return $this->app->make('mailer'); |
|
66
|
|
|
} |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$this->app->singleton( |
|
70
|
|
|
'Illuminate\Contracts\Mail\Mailer', |
|
71
|
|
|
function () { |
|
72
|
|
|
return $this->app->make('mailer'); |
|
73
|
|
|
} |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|