These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PragmaRX\Health\Checkers; |
||
4 | |||
5 | use PragmaRX\Health\Support\Result; |
||
6 | use Illuminate\Support\Facades\Mail as IlluminateMail; |
||
7 | |||
8 | class Mail extends Base |
||
9 | { |
||
10 | /** |
||
11 | * Store mail configuration. |
||
12 | * |
||
13 | * @var |
||
14 | */ |
||
15 | private $mailConfiguration; |
||
16 | |||
17 | /** |
||
18 | * Check resource. |
||
19 | * |
||
20 | * @return Result |
||
21 | */ |
||
22 | public function check() |
||
23 | { |
||
24 | return $this->checkMail(); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Configure mail for testing. |
||
29 | */ |
||
30 | private function configureMail() |
||
31 | { |
||
32 | $this->mailConfiguration = config('mail'); |
||
33 | |||
34 | config(['mail' => $this->target->config->toArray()]); |
||
0 ignored issues
–
show
|
|||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Send a test e-mail. |
||
39 | */ |
||
40 | private function checkMail() |
||
41 | { |
||
42 | $this->configureMail(); |
||
43 | |||
44 | try { |
||
45 | $this->sendMail(); |
||
46 | |||
47 | $result = $this->makeHealthyResult(); |
||
48 | } catch (\Exception $exception) { |
||
49 | report($exception); |
||
50 | |||
51 | $result = $this->makeResultFromException($exception); |
||
52 | } |
||
53 | |||
54 | $this->restoreMailConfiguration(); |
||
55 | |||
56 | return $result; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Restore mail configuration. |
||
61 | */ |
||
62 | private function restoreMailConfiguration() |
||
63 | { |
||
64 | config(['mail' => $this->mailConfiguration]); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Send a test e-mail message. |
||
69 | */ |
||
70 | private function sendMail() |
||
71 | { |
||
72 | IlluminateMail::send($this->target->view, [], function ($message) { |
||
0 ignored issues
–
show
The property
view does not seem to exist in PragmaRX\Health\Support\Target .
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
73 | $fromAddress = array_get($this->target->config, 'from.address'); |
||
0 ignored issues
–
show
The property
config does not seem to exist in PragmaRX\Health\Support\Target .
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
74 | |||
75 | $message->returnPath($fromAddress); |
||
76 | |||
77 | $message->cc($fromAddress); |
||
78 | |||
79 | $message->bcc($fromAddress); |
||
80 | |||
81 | $message->replyTo($fromAddress); |
||
82 | |||
83 | $message->to($this->target->to); |
||
0 ignored issues
–
show
The property
to does not seem to exist in PragmaRX\Health\Support\Target .
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
84 | |||
85 | $message->subject($this->target->subject); |
||
0 ignored issues
–
show
The property
subject does not seem to exist in PragmaRX\Health\Support\Target .
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.
Loading history...
|
|||
86 | }); |
||
87 | } |
||
88 | } |
||
89 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.