MailPhp   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 22 3
A getHeaders() 0 11 1
1
<?php
2
namespace GJClasses;
3
4
class MailPhp
5
{
6
7
    public function send($from_name, $from_address, $reply_name, $reply_address, $recipients, $subject, $message_html)
8
    {
9
        $headers = $this->getHeaders($from_name, $from_address, $reply_name, $reply_address);
10
11
        if ($recipients) {
12
13
            foreach ($recipients as $recipient) {
14
15
                mail($recipient, $subject, $message_html, $headers, "-f " . $from_address);
16
                sleep(2);
17
18
            }
19
20
            $result_message = 'Email Send Succeeded';
21
22
        } else {
23
24
            $result_message = 'Nothing to send';
25
26
        }
27
28
        return $result_message;
29
    }
30
31
    public function getHeaders($from_name, $from_address, $reply_name, $reply_address)
32
    {
33
        $headers = '';
34
        $headers .= 'MIME-Version: 1.0' . "\r\n";
35
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
36
        $headers .= 'From: "' . $from_name . '" <' . $from_address . ">\r\n";
37
        $headers .= 'Return-Path: ' . $from_address . "\r\n";
38
        $headers .= 'Reply-to: "' . $reply_name . '" <' . $reply_address . ">\r\n";
39
        $version = phpversion();
40
        $headers .= 'X-Mailer: PHP/' . $version . "\r\n";
41
        return $headers;
42
    }
43
44
}
45