1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace crocodicstudio\crudbooster\helpers; |
4
|
|
|
|
5
|
|
|
class Mailer |
6
|
|
|
{ |
7
|
|
|
private $attachments; |
8
|
|
|
|
9
|
|
|
private $reciever; |
10
|
|
|
|
11
|
|
|
public function send($config) |
12
|
|
|
{ |
13
|
|
|
$this->setConfigs(); |
14
|
|
|
|
15
|
|
|
$this->reciever = $config['to']; |
16
|
|
|
$template = $config['template']; |
17
|
|
|
|
18
|
|
|
$template = CRUDBooster::first('cms_email_templates', ['slug' => $template]); |
19
|
|
|
$html = $template->content; |
20
|
|
|
foreach ($config['data'] as $key => $val) { |
21
|
|
|
$html = str_replace('['.$key.']', $val, $html); |
22
|
|
|
$template->subject = str_replace('['.$key.']', $val, $template->subject); |
23
|
|
|
} |
24
|
|
|
$subject = $template->subject; |
25
|
|
|
$this->attachments = ($config['attachments']) ?: []; |
26
|
|
|
|
27
|
|
|
$this->sendMail($html, $subject, $template); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
private function setConfigs() |
31
|
|
|
{ |
32
|
|
|
Config::set('mail.driver', SettingRepo::getSetting('smtp_driver')); |
|
|
|
|
33
|
|
|
Config::set('mail.host', SettingRepo::getSetting('smtp_host')); |
34
|
|
|
Config::set('mail.port', SettingRepo::getSetting('smtp_port')); |
35
|
|
|
Config::set('mail.username', SettingRepo::getSetting('smtp_username')); |
36
|
|
|
Config::set('mail.password', SettingRepo::getSetting('smtp_password')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param $html |
41
|
|
|
* @param $subject |
42
|
|
|
* @param $template |
43
|
|
|
*/ |
44
|
|
|
private function sendMail($html, $subject, $template) |
45
|
|
|
{ |
46
|
|
|
\Mail::send("crudbooster::emails.blank", ['content' => $html], function ($message) use ($subject, $template) { |
47
|
|
|
$message->priority(1); |
48
|
|
|
$message->to($this->reciever); |
49
|
|
|
|
50
|
|
|
if ($template->from_email) { |
51
|
|
|
$from_name = ($template->from_name) ?: SettingRepo::getSetting('appname'); |
52
|
|
|
$message->from($template->from_email, $from_name); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if ($template->cc_email) { |
56
|
|
|
$message->cc($template->cc_email); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if (count($this->attachments)) { |
60
|
|
|
foreach ($this->attachments as $attachment) { |
61
|
|
|
$message->attach($attachment); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$message->subject($subject); |
66
|
|
|
}); |
67
|
|
|
} |
68
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths