| 127 | | ); |
| 128 | | /** |
| 129 | | * Name email will been sent from |
| 130 | | * |
| 131 | | * @var string |
| 132 | | * |
| 133 | | * @access private |
| 134 | | */ |
| 135 | | private $_fromName; |
| 136 | | |
| 137 | | /** |
| 138 | | * Address email will be sent from |
| 139 | | * |
| 140 | | * @var string |
| 141 | | * |
| 142 | | * @access private |
| 143 | | */ |
| 144 | | private $_fromEmail; |
| 145 | | |
| 146 | | /** |
| 147 | | * Name email will be sent to |
| 148 | | * |
| 149 | | * @var string |
| 150 | | * |
| 151 | | * @access private |
| 152 | | */ |
| 153 | | private $_toName; |
| 154 | | |
| 155 | | /** |
| 156 | | * Address email will be sent to |
| 157 | | * |
| 158 | | * @var string |
| 159 | | * |
| 160 | | * @access private |
| 161 | | */ |
| 162 | | private $_toEmail; |
| 163 | | |
| 164 | | /** |
| 165 | | * Subject of email |
| 166 | | * |
| 167 | | * @var string |
| 168 | | * |
| 169 | | * @access private |
| 170 | | */ |
| 171 | | private $_subject; |
| 172 | | |
| 173 | | /** |
| 174 | | * Content of email |
| 175 | | * |
| 176 | | * @var string |
| 177 | | * |
| 178 | | * @access private |
| 179 | | */ |
| 180 | | private $_body; |
| 181 | | |
| 182 | | /** |
| 183 | | * Priority of email |
| 184 | | * |
| 185 | | * @var boolean |
| 186 | | * |
| 187 | | * @access private |
| 188 | | */ |
| 189 | | private $_highPriority; |
| 190 | | |
| 191 | | /** |
| 192 | | * Encodes the MIME header |
| 193 | | * |
| 194 | | * @param string $header Header of email |
| 195 | | * |
| 196 | | * @return string Encoded MIME header |
| 197 | | |
| 198 | | * |
| 199 | | * @see http://www.php.net/manual/en/function.mb-send-mail.php |
| 200 | | */ |
| 201 | | private function _encodeMimeHeader($header) { |
| 202 | | // BASE 64 according to the RFC |
| 203 | | $header = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $header); |
| 204 | | $header = str_replace(' ', '_', $header); |
| 205 | | return "=?utf-8?Q?$header?="; |
| 206 | | } |
| 207 | | |
| 208 | | /** |
| 209 | | * Returns name of sender of email |
| 210 | | * |
| 211 | | * @return string Name of sender of email |
| 212 | | * |
| 213 | | * @access public |
| 214 | | */ |
| 215 | | public function getSenderName() { |
| 216 | | return $this->_fromName; |
| 217 | | } |
| 218 | | |
| 219 | | /** |
| 220 | | * Sets name of sender of email |
| 221 | | * |
| 222 | | * @param string $name Name of sender of email |
| 223 | | * |
| 224 | | * @return void |
| 225 | | * |
| 226 | | * @access public |
| 227 | | */ |
| 228 | | public function setSenderName($name) { |
| 229 | | // Encode name |
| 230 | | $this->_fromName = $this->_encodeMimeHeader($name); |
| 231 | | } |
| 232 | | |
| 233 | | /** |
| 234 | | * Returns address of sender of email |
| 235 | | * |
| 236 | | * @return string Address of sender of email |
| 237 | | * |
| 238 | | * @access public |
| 239 | | */ |
| 240 | | public function getSenderEmail() { |
| 241 | | return $this->_fromEmail; |
| 242 | | } |
| 243 | | |
| 244 | | /** |
| 245 | | * Sets address of sender of email |
| 246 | | * |
| 247 | | * @param string $mail Address of sender of email |
| 248 | | * |
| 249 | | * @return void |
| 250 | | * |
| 251 | | * @access public |
| 252 | | */ |
| 253 | | public function setSenderEmail($mail) { |
| 254 | | $this->_fromEmail = $mail; |
| 255 | | } |
| 256 | | |
| 257 | | /** |
| 258 | | * Returns name of recipient of email |
| 259 | | * |
| 260 | | * @return string Name of recipient of email |
| 261 | | * |
| 262 | | * @access public |
| 263 | | */ |
| 264 | | public function getRecipientName() { |
| 265 | | return $this->_toName; |
| 266 | | } |
| 267 | | |
| 268 | | /** |
| 269 | | * Sets name of recipient of email |
| 270 | | * |
| 271 | | * @param string $name Name of recipient of email |
| 272 | | * |
| 273 | | * @return void |
| 274 | | * |
| 275 | | * @access public |
| 276 | | */ |
| 277 | | public function setRecipientName($name) { |
| 278 | | // Encode name |
| 279 | | $this->_toName = $this->_encodeMimeHeader($name); |
| 280 | | } |
| 281 | | |
| 282 | | /** |
| 283 | | * Returns address of recipient of email |
| 284 | | * |
| 285 | | * @return string Address of recipient of email |
| 286 | | * |
| 287 | | * @access public |
| 288 | | */ |
| 289 | | public function getRecipientEmail() { |
| 290 | | return $this->_toEmail; |
| 291 | | } |
| 292 | | |
| 293 | | /** |
| 294 | | * Sets address of recipient of email |
| 295 | | * |
| 296 | | * @param string $mail Address of recipient of email |
| 297 | | * |
| 298 | | * @return void |
| 299 | | * |
| 300 | | * @access public |
| 301 | | */ |
| 302 | | public function setRecipientEmail($mail) { |
| 303 | | $this->_toEmail = $mail; |
| 304 | | } |
| 305 | | |
| 306 | | /** |
| 307 | | * Returns subject of email |
| 308 | | * |
| 309 | | * @return string Subject of email |
| 310 | | * |
| 311 | | * @access public |
| 312 | | */ |
| 313 | | public function getMessageSubject() { |
| 314 | | return $this->_subject; |
| 315 | | } |
| 316 | | |
| 317 | | /** |
| 318 | | * Sets subject of email |
| 319 | | * |
| 320 | | * @param string $subject Subject of email |
| 321 | | * |
| 322 | | * @return void |
| 323 | | * |
| 324 | | * @access public |
| 325 | | */ |
| 326 | | public function setMessageSubject($subject) { |
| 327 | | $this->_subject = $this->_encodeMimeHeader($subject); |
| 328 | | } |
| 329 | | |
| 330 | | /** |
| 331 | | * Returns message body of email |
| 332 | | * |
| 333 | | * @return string Message body of email |
| 334 | | * |
| 335 | | * @access public |
| 336 | | */ |
| 337 | | public function getMessageBody() { |
| 338 | | return $this->_body; |
| 339 | | } |
| 340 | | |
| 341 | | /** |
| 342 | | * Sets message body of email |
| 343 | | * |
| 344 | | * @param string $body Message body of email |
| 345 | | * |
| 346 | | * @return void |
| 347 | | * |
| 348 | | * @access public |
| 349 | | */ |
| 350 | | public function setMessageBody($body) { |
| 351 | | $this->_body = $body; |
| 352 | | } |
| 353 | | |
| 354 | | /** |
| 355 | | * Returns the priority of the email |
| 356 | | * |
| 357 | | * @return boolean Whether high priority or not |
| 358 | | * |
| 359 | | * @access public |
| 360 | | */ |
| 361 | | public function getHighPriority() { |
| 362 | | return $this->_highPriority; |
| 363 | | } |
| 364 | | |
| 365 | | /** |
| 366 | | * Sets the priority of the email |
| 367 | | * |
| 368 | | * @param boolean $boolean Whether high priority or not |
| 369 | | * |
| 370 | | * @return void |
| 371 | | * |
| 372 | | * @access public |
| 373 | | */ |
| 374 | | public function setHighPriority($boolean) { |
| 375 | | $this->_highPriority = $boolean ? true : false; |
| 376 | | } |
| 377 | | |
| 378 | | /** |
| 379 | | * Packs email and sends it according to RFC822 |
| 380 | | * |
| 381 | | * @return bool True if email could be sent |
| 382 | | * |
| 383 | | * @access public |
| 384 | | */ |
| 385 | | public function send() { |
| 386 | | $mail = new PHPMailer(); |
| 387 | | $mail->CharSet = "utf-8"; |
| 388 | | # $mail->SMTPDebug=TRUE; |
| 389 | | |
| 390 | | $mail->Mailer = EMAIL_MAILER; |
| 391 | | if (EMAIL_MAILER == 'smtp') { |
| 392 | | $mail->IsSMTP(); |
| 393 | | $mail->Host = EMAIL_HOST; |
| 394 | | $mail->SMTPAuth = EMAIL_AUTH; |
| 395 | | |
| 396 | | if (EMAIL_AUTH) { |
| 397 | | $mail->Username = EMAIL_USERNAME; |
| 398 | | $mail->Password = EMAIL_PASSWORD; |
| | 125 | ); |
| | 126 | /** |
| | 127 | * Name email will been sent from |
| | 128 | * |
| | 129 | * @var string |
| | 130 | */ |
| | 131 | private $_fromName; |
| | 132 | |
| | 133 | /** |
| | 134 | * Address email will be sent from |
| | 135 | * |
| | 136 | * @var string |
| | 137 | */ |
| | 138 | private $_fromEmail; |
| | 139 | |
| | 140 | /** |
| | 141 | * Name email will be sent to |
| | 142 | * |
| | 143 | * @var string |
| | 144 | */ |
| | 145 | private $_toName; |
| | 146 | |
| | 147 | /** |
| | 148 | * Address email will be sent to |
| | 149 | * |
| | 150 | * @var string |
| | 151 | */ |
| | 152 | private $_toEmail; |
| | 153 | |
| | 154 | /** |
| | 155 | * Subject of email |
| | 156 | * |
| | 157 | * @var string |
| | 158 | */ |
| | 159 | private $_subject; |
| | 160 | |
| | 161 | /** |
| | 162 | * Content of email |
| | 163 | * |
| | 164 | * @var string |
| | 165 | */ |
| | 166 | private $_body; |
| | 167 | |
| | 168 | /** |
| | 169 | * Priority of email |
| | 170 | * |
| | 171 | * @var boolean |
| | 172 | */ |
| | 173 | private $_highPriority; |
| | 174 | |
| | 175 | /** |
| | 176 | * Encodes the MIME header |
| | 177 | * |
| | 178 | * @param string $header Header of email |
| | 179 | * |
| | 180 | * @return string Encoded MIME header |
| | 181 | |
| | 182 | * |
| | 183 | * @see http://www.php.net/manual/en/function.mb-send-mail.php |
| | 184 | */ |
| | 185 | private function _encodeMimeHeader($header) { |
| | 186 | // BASE 64 according to the RFC |
| | 187 | $header = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $header); |
| | 188 | $header = str_replace(' ', '_', $header); |
| | 189 | return "=?utf-8?Q?$header?="; |
| | 190 | } |
| | 191 | |
| | 192 | /** |
| | 193 | * Returns name of sender of email |
| | 194 | * |
| | 195 | * @return string Name of sender of email |
| | 196 | * |
| | 197 | * @access public |
| | 198 | */ |
| | 199 | public function getSenderName() { |
| | 200 | return $this->_fromName; |
| | 201 | } |
| | 202 | |
| | 203 | /** |
| | 204 | * Sets name of sender of email |
| | 205 | * |
| | 206 | * @param string $name Name of sender of email |
| | 207 | * |
| | 208 | * @return void |
| | 209 | * |
| | 210 | * @access public |
| | 211 | */ |
| | 212 | public function setSenderName($name) { |
| | 213 | // Encode name |
| | 214 | $this->_fromName = $this->_encodeMimeHeader($name); |
| | 215 | } |
| | 216 | |
| | 217 | /** |
| | 218 | * Returns address of sender of email |
| | 219 | * |
| | 220 | * @return string Address of sender of email |
| | 221 | * |
| | 222 | * @access public |
| | 223 | */ |
| | 224 | public function getSenderEmail() { |
| | 225 | return $this->_fromEmail; |
| | 226 | } |
| | 227 | |
| | 228 | /** |
| | 229 | * Sets address of sender of email |
| | 230 | * |
| | 231 | * @param string $mail Address of sender of email |
| | 232 | * |
| | 233 | * @return void |
| | 234 | * |
| | 235 | * @access public |
| | 236 | */ |
| | 237 | public function setSenderEmail($mail) { |
| | 238 | $this->_fromEmail = $mail; |
| | 239 | } |
| | 240 | |
| | 241 | /** |
| | 242 | * Returns name of recipient of email |
| | 243 | * |
| | 244 | * @return string Name of recipient of email |
| | 245 | * |
| | 246 | * @access public |
| | 247 | */ |
| | 248 | public function getRecipientName() { |
| | 249 | return $this->_toName; |
| | 250 | } |
| | 251 | |
| | 252 | /** |
| | 253 | * Sets name of recipient of email |
| | 254 | * |
| | 255 | * @param string $name Name of recipient of email |
| | 256 | * |
| | 257 | * @return void |
| | 258 | * |
| | 259 | * @access public |
| | 260 | */ |
| | 261 | public function setRecipientName($name) { |
| | 262 | // Encode name |
| | 263 | $this->_toName = $this->_encodeMimeHeader($name); |
| | 264 | } |
| | 265 | |
| | 266 | /** |
| | 267 | * Returns address of recipient of email |
| | 268 | * |
| | 269 | * @return string Address of recipient of email |
| | 270 | * |
| | 271 | * @access public |
| | 272 | */ |
| | 273 | public function getRecipientEmail() { |
| | 274 | return $this->_toEmail; |
| | 275 | } |
| | 276 | |
| | 277 | /** |
| | 278 | * Sets address of recipient of email |
| | 279 | * |
| | 280 | * @param string $mail Address of recipient of email |
| | 281 | * |
| | 282 | * @return void |
| | 283 | * |
| | 284 | * @access public |
| | 285 | */ |
| | 286 | public function setRecipientEmail($mail) { |
| | 287 | $this->_toEmail = $mail; |
| | 288 | } |
| | 289 | |
| | 290 | /** |
| | 291 | * Returns subject of email |
| | 292 | * |
| | 293 | * @return string Subject of email |
| | 294 | * |
| | 295 | * @access public |
| | 296 | */ |
| | 297 | public function getMessageSubject() { |
| | 298 | return $this->_subject; |
| | 299 | } |
| | 300 | |
| | 301 | /** |
| | 302 | * Sets subject of email |
| | 303 | * |
| | 304 | * @param string $subject Subject of email |
| | 305 | * |
| | 306 | * @return void |
| | 307 | * |
| | 308 | * @access public |
| | 309 | */ |
| | 310 | public function setMessageSubject($subject) { |
| | 311 | $this->_subject = $this->_encodeMimeHeader($subject); |
| | 312 | } |
| | 313 | |
| | 314 | /** |
| | 315 | * Returns message body of email |
| | 316 | * |
| | 317 | * @return string Message body of email |
| | 318 | * |
| | 319 | * @access public |
| | 320 | */ |
| | 321 | public function getMessageBody() { |
| | 322 | return $this->_body; |
| | 323 | } |
| | 324 | |
| | 325 | /** |
| | 326 | * Sets message body of email |
| | 327 | * |
| | 328 | * @param string $body Message body of email |
| | 329 | * |
| | 330 | * @return void |
| | 331 | * |
| | 332 | * @access public |
| | 333 | */ |
| | 334 | public function setMessageBody($body) { |
| | 335 | $this->_body = $body; |
| | 336 | } |
| | 337 | |
| | 338 | /** |
| | 339 | * Returns the priority of the email |
| | 340 | * |
| | 341 | * @return boolean Whether high priority or not |
| | 342 | * |
| | 343 | * @access public |
| | 344 | */ |
| | 345 | public function getHighPriority() { |
| | 346 | return $this->_highPriority; |
| | 347 | } |
| | 348 | |
| | 349 | /** |
| | 350 | * Sets the priority of the email |
| | 351 | * |
| | 352 | * @param boolean $boolean Whether high priority or not |
| | 353 | * |
| | 354 | * @return void |
| | 355 | * |
| | 356 | * @access public |
| | 357 | */ |
| | 358 | public function setHighPriority($boolean) { |
| | 359 | $this->_highPriority = $boolean ? true : false; |
| | 360 | } |
| | 361 | |
| | 362 | /** |
| | 363 | * Packs email and sends it according to RFC822 |
| | 364 | * |
| | 365 | * @return bool True if email could be sent |
| | 366 | * |
| | 367 | * @access public |
| | 368 | */ |
| | 369 | public function send() { |
| | 370 | $phpmailerPath = 'lib/PHPMailer_v2.0.0/'; |
| | 371 | require_once ($phpmailerPath.'class.phpmailer.php'); |
| | 372 | require_once ($phpmailerPath.'class.smtp.php'); |
| | 373 | require_once ('classes/Session.php'); |
| | 374 | $mail = new PHPMailer(); |
| | 375 | $session = Session::getObject(); |
| | 376 | $lang = substr ($session->get(SESS_LANGUAGE_VAR),0,2); |
| | 377 | $mail->SetLanguage($lang, $phpmailerPath.'language/'); |
| | 378 | $mail->CharSet = "utf-8"; |
| | 379 | # $mail->SMTPDebug=TRUE; |
| | 380 | |
| | 381 | $mail->Mailer = EMAIL_MAILER; |
| | 382 | if (EMAIL_MAILER == 'smtp') { |
| | 383 | $mail->IsSMTP(); |
| | 384 | $mail->Host = EMAIL_HOST; |
| | 385 | $mail->SMTPAuth = EMAIL_AUTH; |
| | 386 | |
| | 387 | if (EMAIL_AUTH) { |
| | 388 | $mail->Username = EMAIL_USERNAME; |
| | 389 | $mail->Password = EMAIL_PASSWORD; |
| | 390 | } |