-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathcdashmail.php
48 lines (41 loc) · 1.54 KB
/
cdashmail.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
<?php
/*=========================================================================
Program: CDash - Cross-Platform Dashboard System
Module: $Id$
Language: PHP
Date: $Date$
Version: $Revision$
Copyright (c) Kitware, Inc. All rights reserved.
See LICENSE or http://www.cdash.org/licensing/ for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
use Illuminate\Support\Facades\Mail;
function cdashmail($to, $subject, $body, $headers = false)
{
if (empty($to)) {
add_log('Cannot send email. Recipient is not set.', 'cdashmail', LOG_ERR);
return false;
}
if (config('app.debug')) {
add_log($to, 'TESTING: EMAIL', LOG_DEBUG);
add_log($subject, 'TESTING: EMAILTITLE', LOG_DEBUG);
add_log($body, 'TESTING: EMAILBODY', LOG_DEBUG);
return true;
}
Mail::raw($body, function ($message) use ($to, $subject, $headers) {
$to = is_array($to) ? $to : [$to];
try {
/** @var Illuminate\Mail\Message $message */
$message->subject($subject)
->to($to)
->from(config('mail.from.address'))
->replyTo(config('mail.reply_to.address'));
} catch (\Exception $e) {
\Log::error($e->getMessage());
return false;
}
});
return true;
}