-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail.php
63 lines (47 loc) · 1.3 KB
/
email.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
<?php
class Email {
private $config;
private $recipients;
private $message = "";
private $headers = array();
function __construct($config) {
require_once "Mail.php";
$this->config = $config;
$this->addHeader("From", "<" . $config->email["user"] . ">");
$this->addHeader("MIME-Version", "1.0");
$this->addHeader("Content-type", "text/html; charset=iso-8859-1");
}
/**
* Sets the address to send to
*/
function addRecipient($rec) {
$this->recipients[] = "<" . $rec . ">";
}
/**
* Sets the message
*/
function setMessage($message) {
$this->message = $message;
}
/**
* Adds a header
*/
function addHeader($header, $value) {
$this->headers[$header] = $value;
}
/**
* Sends the email
*/
function send() {
$smtp = Mail::factory('smtp',
array ('host' => $this->config->email["host"],
'port' => $this->config->email["port"],
'auth' => true,
'username' => $this->config->email["user"],
'password' => $this->config->email["pass"]));
$mail = $smtp->send($this->recipients, $this->headers, $this->message);
if (PEAR::isError($mail)) return false;
return true;
}
}
?>