@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | public $connect_port = 25; |
87 | 87 | |
88 | 88 | /** |
89 | - * Are 'catch-all' accounts considered valid or not? |
|
90 | - * If not, the class checks for a "catch-all" and if it determines the box |
|
91 | - * has a "catch-all", sets all the emails on that domain as invalid. |
|
92 | - */ |
|
89 | + * Are 'catch-all' accounts considered valid or not? |
|
90 | + * If not, the class checks for a "catch-all" and if it determines the box |
|
91 | + * has a "catch-all", sets all the emails on that domain as invalid. |
|
92 | + */ |
|
93 | 93 | public $catchall_is_valid = true; |
94 | 94 | public $catchall_test = false; // Set to true to perform a catchall test |
95 | 95 | |
96 | 96 | /** |
97 | - * Being unable to communicate with the remote MTA could mean an address |
|
98 | - * is invalid, but it might not, depending on your use case, set the |
|
99 | - * value appropriately. |
|
100 | - */ |
|
97 | + * Being unable to communicate with the remote MTA could mean an address |
|
98 | + * is invalid, but it might not, depending on your use case, set the |
|
99 | + * value appropriately. |
|
100 | + */ |
|
101 | 101 | public $no_comm_is_valid = false; |
102 | 102 | |
103 | 103 | /** |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | public $greylisted_considered_valid = true; |
112 | 112 | |
113 | 113 | /** |
114 | - * If on Windows (or other places that don't have getmxrr()), this is the |
|
115 | - * nameserver that will be used for MX querying. |
|
116 | - * Set as empty to use the DNS specified via your current network connection. |
|
117 | - * @see getmxrr() |
|
118 | - */ |
|
114 | + * If on Windows (or other places that don't have getmxrr()), this is the |
|
115 | + * nameserver that will be used for MX querying. |
|
116 | + * Set as empty to use the DNS specified via your current network connection. |
|
117 | + * @see getmxrr() |
|
118 | + */ |
|
119 | 119 | // protected $mx_query_ns = 'dns1.t-com.hr'; |
120 | 120 | protected $mx_query_ns = ''; |
121 | 121 | |
122 | 122 | /** |
123 | - * Timeout values for various commands (in seconds) per RFC 2821 |
|
124 | - * @see expect() |
|
125 | - */ |
|
123 | + * Timeout values for various commands (in seconds) per RFC 2821 |
|
124 | + * @see expect() |
|
125 | + */ |
|
126 | 126 | protected $command_timeouts = array( |
127 | 127 | 'ehlo' => 120, |
128 | 128 | 'helo' => 120, |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | ); |
177 | 177 | |
178 | 178 | /** |
179 | - * Constructor. |
|
180 | - * @param $emails array [optional] Array of emails to validate |
|
181 | - * @param $sender string [optional] Email address of the sender/validator |
|
182 | - */ |
|
179 | + * Constructor. |
|
180 | + * @param $emails array [optional] Array of emails to validate |
|
181 | + * @param $sender string [optional] Email address of the sender/validator |
|
182 | + */ |
|
183 | 183 | function __construct($emails = array(), $sender = '') { |
184 | 184 | if (!empty($emails)) { |
185 | 185 | $this->set_emails($emails); |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | - * Disconnects from the SMTP server if needed. |
|
194 | - * @return void |
|
195 | - */ |
|
193 | + * Disconnects from the SMTP server if needed. |
|
194 | + * @return void |
|
195 | + */ |
|
196 | 196 | public function __destruct() { |
197 | 197 | $this->disconnect(false); |
198 | 198 | } |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | - * Performs validation of specified email addresses. |
|
224 | - * @param array $emails Emails to validate (recipient emails) |
|
225 | - * @param string $sender Sender email address |
|
226 | - * @return array List of emails and their results |
|
227 | - */ |
|
223 | + * Performs validation of specified email addresses. |
|
224 | + * @param array $emails Emails to validate (recipient emails) |
|
225 | + * @param string $sender Sender email address |
|
226 | + * @return array List of emails and their results |
|
227 | + */ |
|
228 | 228 | public function validate($emails = array(), $sender = '') { |
229 | 229 | |
230 | 230 | $this->results = array(); |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | - * if we're still connected, proceed (cause we might get |
|
294 | - * disconnected, or banned, or greylisted temporarily etc.) |
|
295 | - * see mail() for more |
|
296 | - */ |
|
293 | + * if we're still connected, proceed (cause we might get |
|
294 | + * disconnected, or banned, or greylisted temporarily etc.) |
|
295 | + * see mail() for more |
|
296 | + */ |
|
297 | 297 | if ($this->connected()) { |
298 | 298 | |
299 | 299 | $this->noop(); |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | - * Helper to set results for all the users on a domain to a specific value |
|
372 | - * @param array $users Array of users (usernames) |
|
373 | - * @param string $domain The domain |
|
374 | - * @param bool $val Value to set |
|
375 | - */ |
|
371 | + * Helper to set results for all the users on a domain to a specific value |
|
372 | + * @param array $users Array of users (usernames) |
|
373 | + * @param string $domain The domain |
|
374 | + * @param bool $val Value to set |
|
375 | + */ |
|
376 | 376 | private function set_domain_results($users, $domain, $val) { |
377 | 377 | if (!is_array($users)) { |
378 | 378 | $users = (array) $users; |
@@ -383,20 +383,20 @@ discard block |
||
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
386 | - * Returns true if we're connected to an MTA |
|
387 | - * @return bool |
|
388 | - */ |
|
386 | + * Returns true if we're connected to an MTA |
|
387 | + * @return bool |
|
388 | + */ |
|
389 | 389 | protected function connected() { |
390 | 390 | return is_resource($this->socket); |
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Tries to connect to the specified host on the pre-configured port. |
|
395 | - * @param string $host The host to connect to |
|
396 | - * @return void |
|
397 | - * @throws SMTP_Validate_Email_Exception_No_Connection |
|
398 | - * @throws SMTP_Validate_Email_Exception_No_Timeout |
|
399 | - */ |
|
394 | + * Tries to connect to the specified host on the pre-configured port. |
|
395 | + * @param string $host The host to connect to |
|
396 | + * @return void |
|
397 | + * @throws SMTP_Validate_Email_Exception_No_Connection |
|
398 | + * @throws SMTP_Validate_Email_Exception_No_Timeout |
|
399 | + */ |
|
400 | 400 | protected function connect($host) { |
401 | 401 | $remote_socket = $host . ':' . $this->connect_port; |
402 | 402 | $errnum = 0; |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
429 | - * Disconnects the currently connected MTA. |
|
430 | - * @param bool $quit Issue QUIT before closing the socket on our end. |
|
431 | - * @return void |
|
432 | - */ |
|
429 | + * Disconnects the currently connected MTA. |
|
430 | + * @param bool $quit Issue QUIT before closing the socket on our end. |
|
431 | + * @return void |
|
432 | + */ |
|
433 | 433 | protected function disconnect($quit = true) { |
434 | 434 | if ($quit) { |
435 | 435 | $this->quit(); |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
446 | - * Resets internal state flags to defaults |
|
447 | - */ |
|
446 | + * Resets internal state flags to defaults |
|
447 | + */ |
|
448 | 448 | private function reset_state() { |
449 | 449 | $this->state['helo'] = false; |
450 | 450 | $this->state['mail'] = false; |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
455 | - * Sends a HELO/EHLO sequence |
|
456 | - * @todo Implement TLS |
|
457 | - * @return bool|null True if successful, false otherwise |
|
458 | - */ |
|
455 | + * Sends a HELO/EHLO sequence |
|
456 | + * @todo Implement TLS |
|
457 | + * @return bool|null True if successful, false otherwise |
|
458 | + */ |
|
459 | 459 | protected function helo() { |
460 | 460 | // don't try if it was already done |
461 | 461 | if ($this->state['helo']) { |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
492 | - * Send EHLO or HELO, depending on what's supported by the remote host. |
|
493 | - * @return void |
|
494 | - */ |
|
492 | + * Send EHLO or HELO, depending on what's supported by the remote host. |
|
493 | + * @return void |
|
494 | + */ |
|
495 | 495 | protected function ehlo() { |
496 | 496 | try { |
497 | 497 | // modern |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
508 | - * Sends a MAIL FROM command to indicate the sender. |
|
509 | - * @param string $from The "From:" address |
|
510 | - * @return bool If MAIL FROM command was accepted or not |
|
511 | - * @throws SMTP_Validate_Email_Exception_No_Helo |
|
512 | - */ |
|
508 | + * Sends a MAIL FROM command to indicate the sender. |
|
509 | + * @param string $from The "From:" address |
|
510 | + * @return bool If MAIL FROM command was accepted or not |
|
511 | + * @throws SMTP_Validate_Email_Exception_No_Helo |
|
512 | + */ |
|
513 | 513 | protected function mail($from) { |
514 | 514 | if (!$this->state['helo']) { |
515 | 515 | throw new SMTP_Validate_Email_Exception_No_Helo('Need HELO before MAIL FROM'); |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
536 | - * Sends a RCPT TO command to indicate a recipient. |
|
537 | - * @param string $to Recipient's email address |
|
538 | - * @return bool Is the recipient accepted |
|
539 | - * @throws SMTP_Validate_Email_Exception_No_Mail_From |
|
540 | - */ |
|
536 | + * Sends a RCPT TO command to indicate a recipient. |
|
537 | + * @param string $to Recipient's email address |
|
538 | + * @return bool Is the recipient accepted |
|
539 | + * @throws SMTP_Validate_Email_Exception_No_Mail_From |
|
540 | + */ |
|
541 | 541 | protected function rcpt($to) { |
542 | 542 | // need to have issued MAIL FROM first |
543 | 543 | if (!$this->state['mail']) { |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | - * Sends a RSET command and resets our internal state. |
|
573 | - * @return void |
|
574 | - */ |
|
572 | + * Sends a RSET command and resets our internal state. |
|
573 | + * @return void |
|
574 | + */ |
|
575 | 575 | protected function rset() { |
576 | 576 | $this->send('RSET'); |
577 | 577 | // MS ESMTP doesn't follow RFC according to ZF tracker, see [ZF-1377] |
@@ -588,9 +588,9 @@ discard block |
||
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
591 | - * Sends a QUIT command. |
|
592 | - * @return void |
|
593 | - */ |
|
591 | + * Sends a QUIT command. |
|
592 | + * @return void |
|
593 | + */ |
|
594 | 594 | protected function quit() { |
595 | 595 | // although RFC says QUIT can be issued at any time, we won't |
596 | 596 | if ($this->state['helo']) { |
@@ -600,9 +600,9 @@ discard block |
||
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
603 | - * Sends a NOOP command. |
|
604 | - * @return void |
|
605 | - */ |
|
603 | + * Sends a NOOP command. |
|
604 | + * @return void |
|
605 | + */ |
|
606 | 606 | protected function noop() { |
607 | 607 | $this->send('NOOP'); |
608 | 608 | // erg... "SMTP" code fix some bad RFC implementations |
@@ -620,12 +620,12 @@ discard block |
||
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
623 | - * Sends a command to the remote host. |
|
624 | - * @param string $cmd The cmd to send |
|
625 | - * @return int|bool Number of bytes written to the stream |
|
626 | - * @throws SMTP_Validate_Email_Exception_No_Connection |
|
627 | - * @throws SMTP_Validate_Email_Exception_Send_Failed |
|
628 | - */ |
|
623 | + * Sends a command to the remote host. |
|
624 | + * @param string $cmd The cmd to send |
|
625 | + * @return int|bool Number of bytes written to the stream |
|
626 | + * @throws SMTP_Validate_Email_Exception_No_Connection |
|
627 | + * @throws SMTP_Validate_Email_Exception_Send_Failed |
|
628 | + */ |
|
629 | 629 | protected function send($cmd) { |
630 | 630 | // must be connected |
631 | 631 | if (!$this->connected()) { |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
646 | - * Receives a response line from the remote host. |
|
647 | - * @param int $timeout Timeout in seconds |
|
648 | - * @return string |
|
649 | - * @throws SMTP_Validate_Email_Exception_No_Connection |
|
650 | - * @throws SMTP_Validate_Email_Exception_Timeout |
|
651 | - * @throws SMTP_Validate_Email_Exception_No_Response |
|
652 | - */ |
|
646 | + * Receives a response line from the remote host. |
|
647 | + * @param int $timeout Timeout in seconds |
|
648 | + * @return string |
|
649 | + * @throws SMTP_Validate_Email_Exception_No_Connection |
|
650 | + * @throws SMTP_Validate_Email_Exception_Timeout |
|
651 | + * @throws SMTP_Validate_Email_Exception_No_Response |
|
652 | + */ |
|
653 | 653 | protected function recv($timeout = null) { |
654 | 654 | if (!$this->connected()) { |
655 | 655 | throw new SMTP_Validate_Email_Exception_No_Connection('No connection'); |
@@ -674,13 +674,13 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
677 | - * Receives lines from the remote host and looks for expected response codes. |
|
678 | - * @param int|int[] $codes A list of one or more expected response codes |
|
679 | - * @param int $timeout The timeout for this individual command, if any |
|
680 | - * @param bool $empty_response_allowed When true, empty responses are allowed |
|
681 | - * @return string The last text message received |
|
682 | - * @throws SMTP_Validate_Email_Exception_Unexpected_Response |
|
683 | - */ |
|
677 | + * Receives lines from the remote host and looks for expected response codes. |
|
678 | + * @param int|int[] $codes A list of one or more expected response codes |
|
679 | + * @param int $timeout The timeout for this individual command, if any |
|
680 | + * @param bool $empty_response_allowed When true, empty responses are allowed |
|
681 | + * @return string The last text message received |
|
682 | + * @throws SMTP_Validate_Email_Exception_Unexpected_Response |
|
683 | + */ |
|
684 | 684 | protected function expect($codes, $timeout = null, $empty_response_allowed = false) { |
685 | 685 | if (!is_array($codes)) { |
686 | 686 | $codes = (array) $codes; |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | } |
713 | 713 | |
714 | 714 | /** |
715 | - * Parses an email string into respective user and domain parts and |
|
716 | - * returns those as an array. |
|
717 | - * @param string $email 'user@domain' |
|
718 | - * @return array ['user', 'domain'] |
|
719 | - */ |
|
715 | + * Parses an email string into respective user and domain parts and |
|
716 | + * returns those as an array. |
|
717 | + * @param string $email 'user@domain' |
|
718 | + * @return array ['user', 'domain'] |
|
719 | + */ |
|
720 | 720 | protected function parse_email($email) { |
721 | 721 | $parts = explode('@', $email); |
722 | 722 | $domain = array_pop($parts); |
@@ -725,10 +725,10 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | /** |
728 | - * Sets the email addresses that should be validated. |
|
729 | - * @param array $emails Array of emails to validate |
|
730 | - * @return void |
|
731 | - */ |
|
728 | + * Sets the email addresses that should be validated. |
|
729 | + * @param array $emails Array of emails to validate |
|
730 | + * @return void |
|
731 | + */ |
|
732 | 732 | public function set_emails($emails) { |
733 | 733 | if (!is_array($emails)) { |
734 | 734 | $emails = (array) $emails; |
@@ -744,10 +744,10 @@ discard block |
||
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
747 | - * Sets the email address to use as the sender/validator. |
|
748 | - * @param string $email |
|
749 | - * @return void |
|
750 | - */ |
|
747 | + * Sets the email address to use as the sender/validator. |
|
748 | + * @param string $email |
|
749 | + * @return void |
|
750 | + */ |
|
751 | 751 | public function set_sender($email) { |
752 | 752 | $parts = $this->parse_email($email); |
753 | 753 | $this->from_user = $parts[0]; |
@@ -755,10 +755,10 @@ discard block |
||
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
758 | - * Queries the DNS server for MX entries of a certain domain. |
|
759 | - * @param string $domain The domain for which to retrieve MX records |
|
760 | - * @return array MX hosts and their weights |
|
761 | - */ |
|
758 | + * Queries the DNS server for MX entries of a certain domain. |
|
759 | + * @param string $domain The domain for which to retrieve MX records |
|
760 | + * @return array MX hosts and their weights |
|
761 | + */ |
|
762 | 762 | protected function mx_query($domain) { |
763 | 763 | $hosts = array(); |
764 | 764 | $weight = array(); |
@@ -813,11 +813,11 @@ discard block |
||
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
816 | - * Debug helper. If run in a CLI env, it just dumps $str on a new line, |
|
817 | - * else it prints stuff using <pre>. |
|
818 | - * @param string $str The debug message |
|
819 | - * @return void |
|
820 | - */ |
|
816 | + * Debug helper. If run in a CLI env, it just dumps $str on a new line, |
|
817 | + * else it prints stuff using <pre>. |
|
818 | + * @param string $str The debug message |
|
819 | + * @return void |
|
820 | + */ |
|
821 | 821 | private function debug($str) { |
822 | 822 | $str = $this->stamp($str); |
823 | 823 | $this->log($str); |
@@ -830,9 +830,9 @@ discard block |
||
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
833 | - * Adds a message to the log array |
|
834 | - * @param string $msg The message to add |
|
835 | - */ |
|
833 | + * Adds a message to the log array |
|
834 | + * @param string $msg The message to add |
|
835 | + */ |
|
836 | 836 | private function log($msg) { |
837 | 837 | $this->log[] = $msg; |
838 | 838 | } |
@@ -852,15 +852,15 @@ discard block |
||
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
855 | - * Returns the log array |
|
856 | - */ |
|
855 | + * Returns the log array |
|
856 | + */ |
|
857 | 857 | public function get_log() { |
858 | 858 | return $this->log; |
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
862 | - * Truncates the log array |
|
863 | - */ |
|
862 | + * Truncates the log array |
|
863 | + */ |
|
864 | 864 | public function clear_log() { |
865 | 865 | $this->log = array(); |
866 | 866 | } |