Example #1
0
 /**
  * Build a standardized string describing the current SMTP error.
  *
  * @param string $text       Custom string describing the error context.
  * @param PEAR_Error $error  PEAR_Error object.
  * @param integer $e_code    Error code.
  *
  * @throws Horde_Mail_Exception
  */
 protected function _error($text, $error, $e_code)
 {
     /* Split the SMTP response into a code and a response string. */
     list($code, $response) = $this->_smtp->getResponse();
     /* Abort current SMTP transaction. */
     $this->_smtp->rset();
     /* Build our standardized error string. */
     throw new Horde_Mail_Exception($text . ' [SMTP: ' . $error->getMessage() . " (code: {$code}, response: {$response})]", $e_code);
 }
Example #2
0
function smtp_send($from, $recips, $body, $ehlo = "maia")
{
    global $dbh;
    global $lang;
    $select = "SELECT smtp_server, smtp_port FROM maia_config WHERE id = 0";
    $sth = $dbh->query($select);
    if ($row = $sth->fetchrow()) {
        $host = $row["smtp_server"];
        $port = $row["smtp_port"];
    }
    $sth->free();
    $rcpt = explode(" ", $recips);
    /* Create a new Net_SMTP object. */
    if (!($smtp = new Net_SMTP($host, $port, $ehlo))) {
        $smtp->disconnect();
        return "550 " . $lang['error_connect'] . ": " . "Unable to instantiate Net_SMTP object\n";
    }
    /* Connect to the SMTP server. */
    if (PEAR::isError($e = $smtp->connect())) {
        $smtp->disconnect();
        return "550 " . $lang['error_connect'] . ": " . $e->getMessage() . "\n";
    }
    /* Send the 'MAIL FROM:' SMTP command. */
    if (PEAR::isError($smtp->mailFrom($from))) {
        return "550 " . $lang['error_mail'];
    }
    /* Address the message to each of the recipients. */
    foreach ($rcpt as $to) {
        if (PEAR::isError($res = $smtp->rcptTo($to))) {
            $smtp->disconnect();
            return "550 " . $lang['error_rcpt'] . ": " . $res->getMessage() . "\n";
        }
    }
    /* Set the body of the message. */
    if (PEAR::isError($smtp->data($body))) {
        $smtp->disconnect();
        return "550 " . $lang['error_body'];
    }
    $response = $smtp->getResponse();
    /* Disconnect from the SMTP server. */
    $smtp->disconnect();
    return join(" ", $response);
}
Example #3
0
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;
}