forked from opendocman/opendocman
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Email_class.php
153 lines (137 loc) · 3.07 KB
/
Email_class.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/*
Email_class.php - relates email notifications
Copyright (C) 2013-2015 Stephen Lawrence Jr.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
class Email
{
private $full_name;
private $from;
private $subject;
private $body;
private $headers;
private $recipients;
/*
* Constructor
*/
public function Email()
{
}
/**
* @return string
*/
public function getFullName()
{
if (!isset($this->full_name)) {
return false;
}
return $this->full_name;
}
/**
* @param string $full_name
*/
public function setFullName($full_name)
{
$this->full_name = $full_name;
}
/**
* @return string
*/
public function getFrom()
{
return $this->from;
}
/**
* @param string $from
*/
public function setFrom($from)
{
$this->from = $from;
}
/**
* @return string
*/
public function getSubject()
{
return $this->subject;
}
/**
* @param string $subject
*/
public function setSubject($subject)
{
$this->subject = $subject;
}
/**
* @return string
*/
public function getBody()
{
return $this->body;
}
/**
* @param string $body
*/
public function setBody($body)
{
$this->body = $body;
}
/**
* @return string
*/
public function getHeaders()
{
return $this->headers;
}
/**
*
*/
private function setHeaders()
{
if(isset($this->from)) {
$mail_headers = "From: {$this->getFrom()}" . PHP_EOL;
$mail_headers .="Content-Type: text/plain; charset=UTF-8" . PHP_EOL;
$this->headers = $mail_headers;
}
}
/**
* @return string
*/
public function getRecipients()
{
return $this->recipients;
}
/**
* @param string $recipients
* @return bool
*/
public function setRecipients($recipients)
{
if (!is_array($recipients)) {
return false;
}
$this->recipients = $recipients;
}
/**
* @return bool
*/
public function sendEmail()
{
if ((count($this->getRecipients()) > 0)) {
$this->setHeaders();
email_users_id($this->getRecipients(), $this->getSubject(), $this->getBody(), $this->getHeaders());
}
return true;
}
}