/** */ public function send($recipients, array $headers, $body) { $headers = $this->_sanitizeHeaders($headers); // Prepare headers list($from, $textHeaders) = $this->prepareHeaders($headers); try { $from = $this->_getFrom($from, $headers); } catch (Horde_Mail_Exception $e) { $this->_error('no_from'); } // Prepare recipients foreach ($this->parseRecipients($recipients) as $rcpt) { list(, $host) = explode('@', $rcpt); $mx = $this->_getMx($host); if (!$mx) { $this->_error('no_mx', array('rcpt' => $rcpt)); } $connected = false; foreach (array_keys($mx) as $mserver) { $this->_smtp = new Net_SMTP($mserver, $this->_params['port'], $this->_params['mailname']); // configure the SMTP connection. if ($this->_params['debug']) { $this->_smtp->setDebug(true); } // attempt to connect to the configured SMTP server. $res = $this->_smtp->connect($this->_params['timeout']); if ($res instanceof PEAR_Error) { $this->_smtp = null; continue; } // connection established if ($res) { $connected = true; break; } } if (!$connected) { $this->_error('not_connected', array('host' => implode(', ', array_keys($mx)), 'port' => $this->_params['port'], 'rcpt' => $rcpt)); } // Verify recipient if ($this->_params['vrfy']) { $res = $this->_smtp->vrfy($rcpt); if ($res instanceof PEAR_Error) { $this->_error('failed_vrfy_rcpt', array('rcpt' => $rcpt)); } } // mail from: $args['verp'] = $this->_params['verp']; $res = $this->_smtp->mailFrom($from, $args); if ($res instanceof PEAR_Error) { $this->_error('failed_set_from', array('from' => $from)); } // rcpt to: $res = $this->_smtp->rcptTo($rcpt); if ($res instanceof PEAR_Error) { $this->_error('failed_set_rcpt', array('rcpt' => $rcpt)); } // Don't send anything in test mode if ($this->_params['test']) { $res = $this->_smtp->rset(); if ($res instanceof PEAR_Error) { $this->_error('failed_rset'); } $this->_smtp->disconnect(); $this->_smtp = null; return; } // Send data. Net_SMTP does necessary EOL conversions. $res = $this->_smtp->data($body, $textHeaders); if ($res instanceof PEAR_Error) { $this->_error('failed_send_data', array('rcpt' => $rcpt)); } $this->_smtp->disconnect(); $this->_smtp = null; } }
function _verifyEmail($email) { if ($arrMxRRs = _getMXHosts($email)) { require_once ASCMS_LIBRARY_PATH . '/PEAR/Net/SMTP.php'; foreach ($arrMxRRs as $arrMxRR) { if (!\PEAR::isError($objSMTP = new \Net_SMTP($arrMxRR['EXCHANGE'])) && !\PEAR::isError($objSMTP->connect(2)) && !\PEAR::isError($e = $objSMTP->vrfy($email))) { return $objSMTP->getResponse(); } } return 0; } return false; }