-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMailHelper.php
71 lines (58 loc) · 1.76 KB
/
MailHelper.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
64
65
66
67
68
69
70
71
<?php
namespace Padosoft\Laravel\Google\StructuredDataTestingTool;
use Config;
use Validator;
use Illuminate\Console\Command;
use Mail;
class MailHelper
{
protected $command;
/**
*
*/
public function setUp()
{
parent::setUp();
}
/**
* MailHelper constructor.
* @param Command $objcommand
*/
public function __construct(Command $objcommand)
{
$this->command = $objcommand;
}
/**
* @param $tuttoOk
* @param $mail
* @param $vul
*/
public function sendEmail($tuttoOk, $mail, $vul)
{
$soggetto = Config::get('laravel-google-structured-data-testing-tool.mailSubjectSuccess');
if (!$tuttoOk) {
$soggetto = Config::get('laravel-google-structured-data-testing-tool.mailSubjetcAlarm');
}
$validator = Validator::make(['email' => $mail], [
'email' => 'required|email',
]);
if ($validator->fails()) {
$this->command->error('No valid email passed: ' . $mail . '. Mail will not be sent.');
return;
}
$this->command->line('Send email to <info>' . $mail . '</info>');
Mail::send(
Config::get('laravel-google-structured-data-testing-tool.mailViewName'),
['vul' => $vul],
function (\Illuminate\Mail\Message $message) use ($mail, $soggetto) {
$message->from(
Config::get('laravel-google-structured-data-testing-tool.mailFrom'),
Config::get('laravel-google-structured-data-testing-tool.mailFromName')
);
$message->to($mail, $mail);
$message->subject($soggetto);
}
);
$this->command->line('email sent.');
}
}