@@ -64,8 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function addTo($address, $title = '') |
| 66 | 66 | { |
| 67 | - if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) |
|
| 68 | - $this->to_array[] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 67 | + if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) { |
|
| 68 | + $this->to_array[] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 69 | + } |
|
| 69 | 70 | |
| 70 | 71 | return $this; |
| 71 | 72 | } |
@@ -79,8 +80,9 @@ discard block |
||
| 79 | 80 | */ |
| 80 | 81 | public function addCC($address, $title = '') |
| 81 | 82 | { |
| 82 | - if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) |
|
| 83 | - $this->cc_array[] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 83 | + if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) { |
|
| 84 | + $this->cc_array[] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | return $this; |
| 86 | 88 | } |
@@ -94,8 +96,9 @@ discard block |
||
| 94 | 96 | */ |
| 95 | 97 | public function addBCC($address, $title = '') |
| 96 | 98 | { |
| 97 | - if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) |
|
| 98 | - $this->bcc_array[] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 99 | + if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) { |
|
| 100 | + $this->bcc_array[] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 101 | + } |
|
| 99 | 102 | |
| 100 | 103 | return $this; |
| 101 | 104 | } |
@@ -109,8 +112,9 @@ discard block |
||
| 109 | 112 | */ |
| 110 | 113 | public function setFrom($address, $title = '') |
| 111 | 114 | { |
| 112 | - if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) |
|
| 113 | - $this->header_array['From'] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 115 | + if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) { |
|
| 116 | + $this->header_array['From'] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 117 | + } |
|
| 114 | 118 | |
| 115 | 119 | return $this; |
| 116 | 120 | } |
@@ -124,8 +128,9 @@ discard block |
||
| 124 | 128 | */ |
| 125 | 129 | public function setReplyTo($address, $title = '') |
| 126 | 130 | { |
| 127 | - if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) |
|
| 128 | - $this->header_array['Reply-To'] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 131 | + if($this->is_valid_email_address($address) && $this->is_valid_email_title($title)) { |
|
| 132 | + $this->header_array['Reply-To'] = ($title != '') ? "\"{$title}\" <{$address}>" : "{$address}"; |
|
| 133 | + } |
|
| 129 | 134 | |
| 130 | 135 | return $this; |
| 131 | 136 | } |
@@ -138,8 +143,9 @@ discard block |
||
| 138 | 143 | */ |
| 139 | 144 | public function setSubject($subject) |
| 140 | 145 | { |
| 141 | - if($this->is_valid_subject($subject)) |
|
| 142 | - $this->subject = $subject; |
|
| 146 | + if($this->is_valid_subject($subject)) { |
|
| 147 | + $this->subject = $subject; |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | return $this; |
| 145 | 151 | } |
@@ -197,11 +203,13 @@ discard block |
||
| 197 | 203 | */ |
| 198 | 204 | public function send() |
| 199 | 205 | { |
| 200 | - if($this->passed_validation === FALSE) |
|
| 201 | - return false; |
|
| 206 | + if($this->passed_validation === FALSE) { |
|
| 207 | + return false; |
|
| 208 | + } |
|
| 202 | 209 | |
| 203 | - if(!$this->check_required_fields()) |
|
| 204 | - return false; |
|
| 210 | + if(!$this->check_required_fields()) { |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 205 | 213 | |
| 206 | 214 | $to = $this->get_to(); |
| 207 | 215 | $subject = $this->subject; |
@@ -256,8 +264,9 @@ discard block |
||
| 256 | 264 | { |
| 257 | 265 | $message = ''; |
| 258 | 266 | |
| 259 | - if(isset($this->attachment_array) && count($this->attachment_array) > 0) |
|
| 260 | - $message .= "--{$this->get_boundary()}" . self::$LINE_BREAK; |
|
| 267 | + if(isset($this->attachment_array) && count($this->attachment_array) > 0) { |
|
| 268 | + $message .= "--{$this->get_boundary()}" . self::$LINE_BREAK; |
|
| 269 | + } |
|
| 261 | 270 | |
| 262 | 271 | if( |
| 263 | 272 | isset($this->plain_message) && strlen($this->plain_message) > 0 && |
@@ -282,8 +291,7 @@ discard block |
||
| 282 | 291 | $message .= self::$LINE_BREAK; |
| 283 | 292 | $message .= "--{$this->get_alternative_boundary()}--" . self::$LINE_BREAK; |
| 284 | 293 | $message .= self::$LINE_BREAK; |
| 285 | - } |
|
| 286 | - else if(isset($this->plain_message) && strlen($this->plain_message)) |
|
| 294 | + } else if(isset($this->plain_message) && strlen($this->plain_message)) |
|
| 287 | 295 | { |
| 288 | 296 | if(isset($this->attachment_array) && count($this->attachment_array) > 0) |
| 289 | 297 | { |
@@ -293,8 +301,7 @@ discard block |
||
| 293 | 301 | } |
| 294 | 302 | $message .= $this->plain_message; |
| 295 | 303 | $message .= self::$LINE_BREAK; |
| 296 | - } |
|
| 297 | - else if(isset($this->html_message) && strlen($this->html_message)) |
|
| 304 | + } else if(isset($this->html_message) && strlen($this->html_message)) |
|
| 298 | 305 | { |
| 299 | 306 | if(isset($this->attachment_array) && count($this->attachment_array) > 0) |
| 300 | 307 | { |
@@ -331,8 +338,9 @@ discard block |
||
| 331 | 338 | private $boundary; |
| 332 | 339 | private function get_boundary() |
| 333 | 340 | { |
| 334 | - if(!isset($this->boundary)) |
|
| 335 | - $this->boundary = sprintf(self::$BOUNDARY_FORMAT, md5(date('r', time()) . self::$BOUNDARY_SALT)); |
|
| 341 | + if(!isset($this->boundary)) { |
|
| 342 | + $this->boundary = sprintf(self::$BOUNDARY_FORMAT, md5(date('r', time()) . self::$BOUNDARY_SALT)); |
|
| 343 | + } |
|
| 336 | 344 | return $this->boundary; |
| 337 | 345 | } |
| 338 | 346 | |
@@ -345,8 +353,9 @@ discard block |
||
| 345 | 353 | private $alternative_boundary; |
| 346 | 354 | private function get_alternative_boundary() |
| 347 | 355 | { |
| 348 | - if(!isset($this->alternative_boundary)) |
|
| 349 | - $this->alternative_boundary = sprintf(self::$ALTERNATIVE_BOUNDARY_FORMAT, md5(date('r', time()) . self::$ALTERNATIVE_BOUNDARY_SALT)); |
|
| 356 | + if(!isset($this->alternative_boundary)) { |
|
| 357 | + $this->alternative_boundary = sprintf(self::$ALTERNATIVE_BOUNDARY_FORMAT, md5(date('r', time()) . self::$ALTERNATIVE_BOUNDARY_SALT)); |
|
| 358 | + } |
|
| 350 | 359 | return $this->alternative_boundary; |
| 351 | 360 | } |
| 352 | 361 | |
@@ -363,21 +372,23 @@ discard block |
||
| 363 | 372 | $headers .= "{$key}: {$value}" . self::$LINE_BREAK; |
| 364 | 373 | } |
| 365 | 374 | |
| 366 | - if(count($this->cc_array) > 0) |
|
| 367 | - $headers .= 'CC: ' . implode(', ', $this->cc_array) . self::$LINE_BREAK; |
|
| 368 | - if(count($this->bcc_array) > 0) |
|
| 369 | - $headers .= 'BCC: ' . implode(', ', $this->bcc_array) . self::$LINE_BREAK; |
|
| 375 | + if(count($this->cc_array) > 0) { |
|
| 376 | + $headers .= 'CC: ' . implode(', ', $this->cc_array) . self::$LINE_BREAK; |
|
| 377 | + } |
|
| 378 | + if(count($this->bcc_array) > 0) { |
|
| 379 | + $headers .= 'BCC: ' . implode(', ', $this->bcc_array) . self::$LINE_BREAK; |
|
| 380 | + } |
|
| 370 | 381 | |
| 371 | - if(isset($this->attachment_array) && count($this->attachment_array) > 0) |
|
| 372 | - $headers .= "Content-Type: multipart/mixed; boundary=\"{$this->get_boundary()}\""; |
|
| 373 | - else if( |
|
| 382 | + if(isset($this->attachment_array) && count($this->attachment_array) > 0) { |
|
| 383 | + $headers .= "Content-Type: multipart/mixed; boundary=\"{$this->get_boundary()}\""; |
|
| 384 | + } else if( |
|
| 374 | 385 | isset($this->plain_message) && strlen($this->plain_message) > 0 && |
| 375 | 386 | isset($this->html_message) && strlen($this->html_message) > 0) |
| 376 | 387 | { |
| 377 | 388 | $headers .= "Content-Type: multipart/alternative; boundary=\"{$this->get_alternative_boundary()}\""; |
| 389 | + } else if(isset($this->html_message) && strlen($this->html_message) > 0) { |
|
| 390 | + $headers .= 'Content-type: text/html; charset="iso-8859-1"'; |
|
| 378 | 391 | } |
| 379 | - else if(isset($this->html_message) && strlen($this->html_message) > 0) |
|
| 380 | - $headers .= 'Content-type: text/html; charset="iso-8859-1"'; |
|
| 381 | 392 | |
| 382 | 393 | return $headers; |
| 383 | 394 | } |
@@ -403,8 +414,9 @@ discard block |
||
| 403 | 414 | */ |
| 404 | 415 | private function is_valid_email_address($string) |
| 405 | 416 | { |
| 406 | - if(strlen($string) < 1) |
|
| 407 | - return $this->fail_validation("{$string} is an invalid email address!"); |
|
| 417 | + if(strlen($string) < 1) { |
|
| 418 | + return $this->fail_validation("{$string} is an invalid email address!"); |
|
| 419 | + } |
|
| 408 | 420 | |
| 409 | 421 | return true; |
| 410 | 422 | } |
@@ -422,8 +434,9 @@ discard block |
||
| 422 | 434 | */ |
| 423 | 435 | private function is_valid_subject($string) |
| 424 | 436 | { |
| 425 | - if(strlen($string) < 1) |
|
| 426 | - return $this->fail_validation("{$string} is an invalid email subject!"); |
|
| 437 | + if(strlen($string) < 1) { |
|
| 438 | + return $this->fail_validation("{$string} is an invalid email subject!"); |
|
| 439 | + } |
|
| 427 | 440 | |
| 428 | 441 | return true; |
| 429 | 442 | } |