/** * @param $fromUser * @param $fromDomain * @return bool * @throws \SmtpValidatorEmail\Exception\ExceptionNoMailFrom */ public function rcptEachUser($fromUser, $fromDomain) { $this->transport->getSmtp()->noop(); $iterator = 0; $dynamicTimeout = 0; if (count($this->users) >= $this->options['sameDomainLimit']) { $dynamicTimeout = count($this->users); } foreach ($this->users as $user) { if (!$this->transport->getSmtp()->isConnect()) { $this->establishConnection(); } $address = $user . '@' . $this->dom->getDomain(); // Sets the results to an integer 0 ( failure ) or 1 ( success ) $result = $this->transport->getSmtp()->rcpt($address); if ($this->options['detailResults'] === false) { $this->statusManager->updateStatus($address, $result); } if ($iterator == count($this->users)) { // stop the loop return 1; } $this->transport->getSmtp()->noop(); // if( $iterator > 0 && $iterator % 4 == 0 ){ // $this->transport->disconnect(); // sleep($dynamicTimeout); // } $iterator++; } }
/** * @param $fromUser * @param $fromDomain * @return bool * @throws \SmtpValidatorEmail\Exception\ExceptionNoMailFrom */ public function rcptEachUser($fromUser, $fromDomain) { $this->transport->getSmtp()->noop(); // rcpt to for each user // var_dump("user list :"); // var_dump($this->users); $iterator = 0; $dynamicTimeout = 0; if (count($this->users) >= $this->options['sameDomainLimit']) { $dynamicTimeout = count($this->users); } foreach ($this->users as $user) { // var_dump("Checking user :"******"Connection lost. Reconnect."); $this->establishConnection(); } $address = $user . '@' . $this->dom->getDomain(); // Sets the results to an integer 0 ( failure ) or 1 ( success ) $result = $this->transport->getSmtp()->rcpt($address); // var_dump("The adress $address, was checked , result: $result"); $this->statusManager->updateStatus($address, $result); if ($iterator == count($this->users)) { // stop the loop return 1; } $this->transport->getSmtp()->noop(); // if( $iterator > 0 && $iterator % 4 == 0 ){ // $this->transport->disconnect(); // sleep($dynamicTimeout); // } $iterator++; } }
/** * Sends a RCPT TO command to indicate a recipient. * * @param string $to Recipient's email address * * @return bool Is the recipient accepted * @throws Exception\ExceptionNoMailFrom */ public function rcpt($to) { // need to have issued MAIL FROM first if (!$this->state['mail']) { $this->statusManager->setStatus($this->users, new Domain($this->domain), 0, 'Need MAIL FROM before RCPT TO'); throw new Exception\ExceptionNoMailFrom('Need MAIL FROM before RCPT TO'); } $expectedCodes = array($this->config['responseCodes']['SMTP_GENERIC_SUCCESS'], $this->config['responseCodes']['SMTP_USER_NOT_LOCAL']); if ($this->greyListedConsideredValid) { $expectedCodes = array_merge($expectedCodes, $this->greyListed); } // issue RCPT TO, 5 minute timeout try { $this->send('RCPT TO:<' . $to . '>'); // process the response try { $response = $this->expect($expectedCodes, $this->config['commandTimeouts']['rcpt']); $this->state['rcpt'] = true; $isValid = 1; $this->statusManager->updateStatus($to, array('result' => $isValid, 'info' => "OK: {$response}")); } catch (Exception\ExceptionUnexpectedResponse $e) { $this->statusManager->setStatus($this->users, new Domain($this->domain), 0, 'UnexpectedResponse: ' . $e->getMessage()); $isValid = 0; } } catch (Exception\ExceptionSmtpValidatorEmail $e) { $this->statusManager->setStatus($this->users, new Domain($this->domain), 0, 'Sending RCPT TO failed: ' . $e->getMessage()); $isValid = 0; } return $isValid; }