@@ -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 | } |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | if (!$this->catchall_test) { |
| 202 | 202 | return false; |
| 203 | 203 | } |
| 204 | - $test = 'catch-all-test-' . time(); |
|
| 205 | - $accepted = $this->rcpt($test . '@' . $domain); |
|
| 204 | + $test = 'catch-all-test-'.time(); |
|
| 205 | + $accepted = $this->rcpt($test.'@'.$domain); |
|
| 206 | 206 | if ($accepted) { |
| 207 | 207 | // success on a non-existing address is a "catch-all" |
| 208 | 208 | $this->domains_info[$domain]['catchall'] = true; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | // while trying to perform a catchall detect |
| 213 | 213 | $this->noop(); |
| 214 | 214 | if (!($this->connected())) { |
| 215 | - $this->debug('Disconnected after trying a non-existing recipient on ' . $domain); |
|
| 215 | + $this->debug('Disconnected after trying a non-existing recipient on '.$domain); |
|
| 216 | 216 | } |
| 217 | 217 | // nb: disconnects are considered as a non-catch-all case this way |
| 218 | 218 | // this might not be true always |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | // add the hostname itself with 0 weight (RFC 2821) |
| 258 | 258 | $mxs[$domain] = 0; |
| 259 | 259 | |
| 260 | - $this->debug('MX records (' . $domain . '): ' . print_r($mxs, true)); |
|
| 260 | + $this->debug('MX records ('.$domain.'): '.print_r($mxs, true)); |
|
| 261 | 261 | $this->domains_info[$domain] = array(); |
| 262 | 262 | $this->domains_info[$domain]['users'] = $users; |
| 263 | 263 | $this->domains_info[$domain]['mxs'] = $mxs; |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | } catch (SMTP_Validate_Email_Exception_No_Connection $e) { |
| 274 | 274 | // unable to connect to host, so these addresses are invalid? |
| 275 | - $this->debug('Unable to connect. Exception caught: ' . $e->getMessage()); |
|
| 276 | - $this->set_domain_results($users, $domain, $this->no_conn_is_valid ); |
|
| 275 | + $this->debug('Unable to connect. Exception caught: '.$e->getMessage()); |
|
| 276 | + $this->set_domain_results($users, $domain, $this->no_conn_is_valid); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if ($this->helo()) { |
| 285 | 285 | |
| 286 | 286 | // try issuing MAIL FROM |
| 287 | - if (!($this->mail($this->from_user . '@' . $this->from_domain))) { |
|
| 287 | + if (!($this->mail($this->from_user.'@'.$this->from_domain))) { |
|
| 288 | 288 | // MAIL FROM not accepted, we can't talk |
| 289 | 289 | $this->set_domain_results($users, $domain, $this->no_comm_is_valid); |
| 290 | 290 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $this->noop(); |
| 317 | 317 | // rcpt to for each user |
| 318 | 318 | foreach ($users as $user) { |
| 319 | - $address = $user . '@' . $domain; |
|
| 319 | + $address = $user.'@'.$domain; |
|
| 320 | 320 | $this->results[$address] = $this->rcpt($address); |
| 321 | 321 | $this->noop(); |
| 322 | 322 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $users = (array) $users; |
| 379 | 379 | } |
| 380 | 380 | foreach ($users as $user) { |
| 381 | - $this->results[$user . '@' . $domain] = $val; |
|
| 381 | + $this->results[$user.'@'.$domain] = $val; |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | * @throws SMTP_Validate_Email_Exception_No_Timeout |
| 399 | 399 | */ |
| 400 | 400 | protected function connect($host) { |
| 401 | - $remote_socket = $host . ':' . $this->connect_port; |
|
| 401 | + $remote_socket = $host.':'.$this->connect_port; |
|
| 402 | 402 | $errnum = 0; |
| 403 | 403 | $errstr = ''; |
| 404 | 404 | $this->host = $remote_socket; |
| 405 | 405 | // open connection |
| 406 | - $this->debug('Connecting to ' . $this->host); |
|
| 406 | + $this->debug('Connecting to '.$this->host); |
|
| 407 | 407 | $this->socket = @stream_socket_client( |
| 408 | 408 | $this->host, |
| 409 | 409 | $errnum, |
@@ -414,15 +414,15 @@ discard block |
||
| 414 | 414 | ); |
| 415 | 415 | // connected? |
| 416 | 416 | if (!$this->connected()) { |
| 417 | - $this->debug('Connect failed: ' . $errstr . ', error number: ' . $errnum . ', host: ' . $this->host); |
|
| 418 | - throw new SMTP_Validate_Email_Exception_No_Connection('Cannot ' . |
|
| 419 | - 'open a connection to remote host (' . $this->host . ')'); |
|
| 417 | + $this->debug('Connect failed: '.$errstr.', error number: '.$errnum.', host: '.$this->host); |
|
| 418 | + throw new SMTP_Validate_Email_Exception_No_Connection('Cannot '. |
|
| 419 | + 'open a connection to remote host ('.$this->host.')'); |
|
| 420 | 420 | } |
| 421 | 421 | $result = stream_set_timeout($this->socket, $this->connect_timeout); |
| 422 | 422 | if (!$result) { |
| 423 | 423 | throw new SMTP_Validate_Email_Exception_No_Timeout('Cannot set timeout'); |
| 424 | 424 | } |
| 425 | - $this->debug('Connected to ' . $this->host . ' successfully'); |
|
| 425 | + $this->debug('Connected to '.$this->host.' successfully'); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $this->quit(); |
| 436 | 436 | } |
| 437 | 437 | if ($this->connected()) { |
| 438 | - $this->debug('Closing socket to ' . $this->host); |
|
| 438 | + $this->debug('Closing socket to '.$this->host); |
|
| 439 | 439 | fclose($this->socket); |
| 440 | 440 | } |
| 441 | 441 | $this->host = null; |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | return true; |
| 483 | 483 | } catch (SMTP_Validate_Email_Exception_Unexpected_Response $e) { |
| 484 | 484 | // connected, but recieved an unexpected response, so disconnect |
| 485 | - $this->debug('Unexpected response after connecting: ' . $e->getMessage()); |
|
| 485 | + $this->debug('Unexpected response after connecting: '.$e->getMessage()); |
|
| 486 | 486 | $this->disconnect(false); |
| 487 | 487 | return false; |
| 488 | 488 | } |
@@ -495,11 +495,11 @@ discard block |
||
| 495 | 495 | protected function ehlo() { |
| 496 | 496 | try { |
| 497 | 497 | // modern |
| 498 | - $this->send('EHLO ' . $this->from_domain); |
|
| 498 | + $this->send('EHLO '.$this->from_domain); |
|
| 499 | 499 | $this->expect(self::SMTP_GENERIC_SUCCESS, $this->command_timeouts['ehlo']); |
| 500 | 500 | } catch (SMTP_Validate_Email_Exception_Unexpected_Response $e) { |
| 501 | 501 | // legacy |
| 502 | - $this->send('HELO ' . $this->from_domain); |
|
| 502 | + $this->send('HELO '.$this->from_domain); |
|
| 503 | 503 | $this->expect(self::SMTP_GENERIC_SUCCESS, $this->command_timeouts['helo']); |
| 504 | 504 | } |
| 505 | 505 | } |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | throw new SMTP_Validate_Email_Exception_No_Helo('Need HELO before MAIL FROM'); |
| 516 | 516 | } |
| 517 | 517 | // issue MAIL FROM, 5 minute timeout |
| 518 | - $this->send('MAIL FROM:<' . $from . '>'); |
|
| 518 | + $this->send('MAIL FROM:<'.$from.'>'); |
|
| 519 | 519 | try { |
| 520 | 520 | $this->expect(self::SMTP_GENERIC_SUCCESS, $this->command_timeouts['mail']); |
| 521 | 521 | // set state flags |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | return true; |
| 525 | 525 | } catch (SMTP_Validate_Email_Exception_Unexpected_Response $e) { |
| 526 | 526 | // got something unexpected in response to MAIL FROM |
| 527 | - $this->debug("Unexpected response to MAIL FROM\n:" . $e->getMessage()); |
|
| 527 | + $this->debug("Unexpected response to MAIL FROM\n:".$e->getMessage()); |
|
| 528 | 528 | // hotmail has been known to do this + was closing the connection |
| 529 | 529 | // forcibly on their end, so we're killing the socket here too |
| 530 | 530 | $this->disconnect(false); |
@@ -553,17 +553,17 @@ discard block |
||
| 553 | 553 | } |
| 554 | 554 | // issue RCPT TO, 5 minute timeout |
| 555 | 555 | try { |
| 556 | - $this->send('RCPT TO:<' . $to . '>'); |
|
| 556 | + $this->send('RCPT TO:<'.$to.'>'); |
|
| 557 | 557 | // process the response |
| 558 | 558 | try { |
| 559 | 559 | $this->expect($expected_codes, $this->command_timeouts['rcpt']); |
| 560 | 560 | $this->state['rcpt'] = true; |
| 561 | 561 | $is_valid = true; |
| 562 | 562 | } catch (SMTP_Validate_Email_Exception_Unexpected_Response $e) { |
| 563 | - $this->debug('Unexpected response to RCPT TO: ' . $e->getMessage()); |
|
| 563 | + $this->debug('Unexpected response to RCPT TO: '.$e->getMessage()); |
|
| 564 | 564 | } |
| 565 | 565 | } catch (SMTP_Validate_Email_Exception $e) { |
| 566 | - $this->debug('Sending RCPT TO failed: ' . $e->getMessage()); |
|
| 566 | + $this->debug('Sending RCPT TO failed: '.$e->getMessage()); |
|
| 567 | 567 | } |
| 568 | 568 | return $is_valid; |
| 569 | 569 | } |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | // although RFC says QUIT can be issued at any time, we won't |
| 596 | 596 | if ($this->state['helo']) { |
| 597 | 597 | $this->send('QUIT'); |
| 598 | - $this->expect(array(self::SMTP_GENERIC_SUCCESS,self::SMTP_QUIT_SUCCESS), $this->command_timeouts['quit'], true); |
|
| 598 | + $this->expect(array(self::SMTP_GENERIC_SUCCESS, self::SMTP_QUIT_SUCCESS), $this->command_timeouts['quit'], true); |
|
| 599 | 599 | } |
| 600 | 600 | } |
| 601 | 601 | |
@@ -631,13 +631,13 @@ discard block |
||
| 631 | 631 | if (!$this->connected()) { |
| 632 | 632 | throw new SMTP_Validate_Email_Exception_No_Connection('No connection'); |
| 633 | 633 | } |
| 634 | - $this->debug('send>>>: ' . $cmd); |
|
| 634 | + $this->debug('send>>>: '.$cmd); |
|
| 635 | 635 | // write the cmd to the connection stream |
| 636 | - $result = fwrite($this->socket, $cmd . self::CRLF); |
|
| 636 | + $result = fwrite($this->socket, $cmd.self::CRLF); |
|
| 637 | 637 | // did the send work? |
| 638 | 638 | if ($result === false) { |
| 639 | - throw new SMTP_Validate_Email_Exception_Send_Failed('Send failed ' . |
|
| 640 | - 'on: ' . $this->host); |
|
| 639 | + throw new SMTP_Validate_Email_Exception_Send_Failed('Send failed '. |
|
| 640 | + 'on: '.$this->host); |
|
| 641 | 641 | } |
| 642 | 642 | return $result; |
| 643 | 643 | } |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | } |
| 661 | 661 | // retrieve response |
| 662 | 662 | $line = fgets($this->socket, 1024); |
| 663 | - $this->debug('<<<recv: ' . $line); |
|
| 663 | + $this->debug('<<<recv: '.$line); |
|
| 664 | 664 | // have we timed out? |
| 665 | 665 | $info = stream_get_meta_data($this->socket); |
| 666 | 666 | if (!empty($info['timed_out'])) { |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | // no response in expect() probably means that the |
| 705 | 705 | // remote server forcibly closed the connection so |
| 706 | 706 | // lets clean up on our end as well? |
| 707 | - $this->debug('No response in expect(): ' . $e->getMessage()); |
|
| 707 | + $this->debug('No response in expect(): '.$e->getMessage()); |
|
| 708 | 708 | $this->disconnect(false); |
| 709 | 709 | |
| 710 | 710 | } |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | protected function parse_email($email) { |
| 721 | 721 | $parts = explode('@', $email); |
| 722 | 722 | $domain = array_pop($parts); |
| 723 | - $user= implode('@', $parts); |
|
| 723 | + $user = implode('@', $parts); |
|
| 724 | 724 | return array($user, $domain); |
| 725 | 725 | } |
| 726 | 726 | |
@@ -789,9 +789,9 @@ discard block |
||
| 789 | 789 | if (empty($hostname)) { |
| 790 | 790 | return null; |
| 791 | 791 | } |
| 792 | - $cmd = 'nslookup -type=MX ' . escapeshellarg($hostname); |
|
| 792 | + $cmd = 'nslookup -type=MX '.escapeshellarg($hostname); |
|
| 793 | 793 | if (!empty($this->mx_query_ns)) { |
| 794 | - $cmd .= ' ' . escapeshellarg($this->mx_query_ns); |
|
| 794 | + $cmd .= ' '.escapeshellarg($this->mx_query_ns); |
|
| 795 | 795 | } |
| 796 | 796 | exec($cmd, $output); |
| 797 | 797 | if (empty($output)) { |
@@ -823,9 +823,9 @@ discard block |
||
| 823 | 823 | $this->log($str); |
| 824 | 824 | if ($this->debug == true) { |
| 825 | 825 | if (PHP_SAPI != 'cli') { |
| 826 | - $str = '<br/><pre>' . htmlspecialchars($str) . '</pre>'; |
|
| 826 | + $str = '<br/><pre>'.htmlspecialchars($str).'</pre>'; |
|
| 827 | 827 | } |
| 828 | - echo "\n" . $str; |
|
| 828 | + echo "\n".$str; |
|
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | private function stamp($msg) { |
| 848 | 848 | $date = \DateTime::createFromFormat('U.u', sprintf('%.f', microtime(true)))->format('Y-m-d\TH:i:s.uO'); |
| 849 | - $line = '[' . $date . '] ' . $msg; |
|
| 849 | + $line = '['.$date.'] '.$msg; |
|
| 850 | 850 | |
| 851 | 851 | return $line; |
| 852 | 852 | } |