Completed
Push — master ( ef379e...0b8878 )
by Patrick
03:01
created

FlipsideMail::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 11
rs 9.4285
1
<?php
2
require_once('/var/www/common/libs/PHPMailer/PHPMailerAutoload.php');
3
require_once('/var/www/secure_settings/class.FlipsideSettings.php');
4
class FlipsideMail extends PHPMailer
5
{
6
    public function __construct()
7
    {
8
        parent::__construct();
9
        $this->isSMTP();
10
        $this->SMTPAuth = true;
11
        $this->Host = FlipsideSettings::$smtp['smtp_host']; 
12
        $this->Username = FlipsideSettings::$smtp['smtp_user'];
13
        $this->Password = FlipsideSettings::$smtp['smtp_pass'];
14
        $this->SMTPSecure = FlipsideSettings::$smtp['smtp_proto'];
15
        $this->Port = FlipsideSettings::$smtp['smtp_port'];
16
    }
17
18
    private static function add_to($item1, $key, $mail)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
19
    {
20
        $mail->addAddress($item1);
21
    }
22
23
    public function send_HTML($mail)
24
    {
25
        if(isset($mail['from']))
26
        {
27
            $this->From = $mail['from'];
28
        }
29
        else
30
        {
31
            $this->From = $this->Username;
32
        }
33
        if(isset($mail['from_name']))
34
        {
35
            $this->FromName = $mail['from_name'];
36
        }
37
        else
38
        {
39
            $this->FromName = 'Burning Flipside';
40
        }
41
        $this->clearAllRecipients();
42
        if(is_array($mail['to']))
43
        {
44
            array_walk($mail['to'], 'FlipsideMail::addTo', $this);
45
        }
46
        else
47
        {
48
            $this->addAddress($mail['to']);
49
        }
50
        if(isset($mail['reply_to']))
51
        {
52
            $this->addReplyTo($mail['reply_to']);
53
        }
54
        $this->isHTML(true);
55
56
        $this->Subject = $mail['subject'];
57
        $this->Body    = $mail['body'];
58
        $this->AltBody = $mail['alt_body'];
59
60
        return $this->send();
61
    }
62
}
63
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
64