blob: 4e6c59c89ee49e0b8fc4c007a0781a8f2eca5366 (
plain)
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
|
<?php
/**
* @package OpenCart
* @author Daniel Kerr
* @copyright Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.opencart.com
*/
/**
* Mail class
*/
class Mail {
protected $to;
protected $from;
protected $sender;
protected $reply_to;
protected $subject;
protected $text;
protected $html;
protected $attachments = array();
public $parameter;
/**
* Constructor
*
* @param string $adaptor
*
*/
public function __construct($adaptor = 'mail') {
$class = 'Mail\\' . $adaptor;
if (class_exists($class)) {
$this->adaptor = new $class();
} else {
trigger_error('Error: Could not load mail adaptor ' . $adaptor . '!');
exit();
}
}
/**
*
*
* @param mixed $to
*/
public function setTo($to) {
$this->to = $to;
}
/**
*
*
* @param string $from
*/
public function setFrom($from) {
$this->from = $from;
}
/**
*
*
* @param string $sender
*/
public function setSender($sender) {
$this->sender = $sender;
}
/**
*
*
* @param string $reply_to
*/
public function setReplyTo($reply_to) {
$this->reply_to = $reply_to;
}
/**
*
*
* @param string $subject
*/
public function setSubject($subject) {
$this->subject = $subject;
}
/**
*
*
* @param string $text
*/
public function setText($text) {
$this->text = $text;
}
/**
*
*
* @param string $html
*/
public function setHtml($html) {
$this->html = $html;
}
/**
*
*
* @param string $filename
*/
public function addAttachment($filename) {
$this->attachments[] = $filename;
}
/**
*
*
*/
public function send() {
if (!$this->to) {
throw new \Exception('Error: E-Mail to required!');
}
if (!$this->from) {
throw new \Exception('Error: E-Mail from required!');
}
if (!$this->sender) {
throw new \Exception('Error: E-Mail sender required!');
}
if (!$this->subject) {
throw new \Exception('Error: E-Mail subject required!');
}
if ((!$this->text) && (!$this->html)) {
throw new \Exception('Error: E-Mail message required!');
}
foreach (get_object_vars($this) as $key => $value) {
$this->adaptor->$key = $value;
}
$this->adaptor->send();
}
}
|