/
CakeEmail.php
255 lines (227 loc) · 4.5 KB
/
CakeEmail.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
/**
* Cake E-Mail
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs
* @since CakePHP(tm) v 2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', array('Validation', 'Multibyte'));
/**
* Cake e-mail class.
*
* This class is used for handling Internet Message Format based
* based on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt
*
* @package cake.libs
*/
class CakeEmail {
/**
* Recipient of the email
*
* @var string
*/
public $to = null;
/**
* The mail which the email is sent from
*
* @var string
*/
public $from = null;
/**
* The email the recipient will reply to
*
* @var string
*/
public $replyTo = null;
/**
* The read receipt email
*
* @var string
*/
public $readReceipt = null;
/**
* The mail that will be used in case of any errors like
* - Remote mailserver down
* - Remote user has exceeded his quota
* - Unknown user
*
* @var string
*/
public $return = null;
/**
* Carbon Copy
*
* List of email's that should receive a copy of the email.
* The Recipient WILL be able to see this list
*
* @var array
*/
public $cc = array();
/**
* Blind Carbon Copy
*
* List of email's that should receive a copy of the email.
* The Recipient WILL NOT be able to see this list
*
* @var array
*/
public $bcc = array();
/**
* The date to put in the Date: header. This should be a date
* conformant with the RFC2822 standard. Leave null, to have
* today's date generated.
*
* @var string
*/
var $date = null;
/**
* The subject of the email
*
* @var string
*/
public $subject = null;
/**
* Associative array of a user defined headers
* Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
*
* @var array
*/
public $headers = array();
/**
* List of additional headers
*
* These will NOT be used if you are using safemode and mail()
*
* @var string
*/
public $additionalParams = null;
/**
* Layout for the View
*
* @var string
*/
public $layout = 'default';
/**
* Template for the view
*
* @var string
*/
public $template = null;
/**
* as per RFC2822 Section 2.1.1
*
* @var integer
*/
public $lineLength = 70;
/**
* Line feed character(s) to be used when sending using mail() function
* By default PHP_EOL is used.
* RFC2822 requires it to be CRLF but some Unix
* mail transfer agents replace LF by CRLF automatically
* (which leads to doubling CR if CRLF is used).
*
* @var string
*/
public $lineFeed = PHP_EOL;
/**
* What format should the email be sent in
*
* Supported formats:
* - text
* - html
* - both
*
* @var string
*/
public $sendAs = 'text';
/**
* What method should the email be sent
*
* @var string
*/
public $delivery = 'mail';
/**
* charset the email is sent in
*
* @var string
*/
public $charset = 'utf-8';
/**
* List of files that should be attached to the email.
*
* Can be both absolute and relative paths
*
* @var array
*/
public $attachments = array();
/**
* What mailer should EmailComponent identify itself as
*
* @var string
*/
public $xMailer = 'CakePHP Email Component';
/**
* The list of paths to search if an attachment isnt absolute
*
* @var array
*/
public $filePaths = array();
/**
* Temporary store of message header lines
*
* @var array
*/
protected $_header = array();
/**
* If set, boundary to use for multipart mime messages
*
* @var string
*/
protected $_boundary = null;
/**
* Constructor
*
*/
public function __construct() {
$charset = Configure::read('App.encoding');
if ($charset !== null) {
$this->charset = $charset;
}
}
/**
* Sets headers for the message
*
* @param array Associative array containing headers to be set.
* @return void
*/
public function header($headers) {
foreach ($headers as $header => $value) {
$this->_header[] = sprintf('%s: %s', trim($header), trim($value));
}
}
/**
* Send an email using the specified content, template and layout
*
* @return boolean Success
*/
public function send() {
}
/**
* Reset all EmailComponent internal variables to be able to send out a new email.
*
* @return void
*/
public function reset() {
}
}