Changeset 1413 in ExiteCMS


Ignore:
Timestamp:
05/18/08 01:04:57 (4 years ago)
Author:
hverton
Message:

Fixed check for a valid email address by defining a CheckRecipient() function, which checks not only the SMTP return code, but also the message returned (to capture p.e. greylisting).

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/edit_profile.php

    r1281 r1413  
    9696                                $error .= sprintf($locale['489'], $email_domain)."<br><br>\n"; 
    9797                            } else { 
    98                                 if (!$mail->Recipient($email)) { 
     98                                if (!$mail->CheckRecipient($email)) { 
    9999                                    // mail server doesn't respond to RCPT TO message 
    100100                                    $error .= sprintf($locale['490'], $email, $mailhost)."<br><br>\n"; 
  • trunk/includes/smtp_include.php

    r1412 r1413  
    714714     * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> 
    715715     * 
    716      * SMTP CODE SUCCESS: 250,251,450("greylisted") 
     716     * SMTP CODE SUCCESS: 250,251 
    717717     * SMTP CODE FAILURE: 550,551,552,553,450,451,452 
    718718     * SMTP CODE ERROR  : 500,501,503,421 
     
    738738        } 
    739739 
    740         if($code != 250 && $code != 251 && ($code == 450 && strpos(strtolower($reply), "greylist")===false)) { 
     740        if($code != 250 && $code != 251) { 
    741741            $this->error = 
    742742                array("error" => "RCPT not accepted from server", 
     
    750750        } 
    751751        return true; 
     752    } 
     753 
     754    /** 
     755     * Sends the command RCPT to the SMTP server with the TO: argument of $to. 
     756     * Returns true if the recipient was accepted false if it was rejected. 
     757     * 
     758     * Implements some extra SUCCESS codes, based on the reply text 
     759     * 
     760     * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> 
     761     * 
     762     * SMTP CODE SUCCESS: 250,251 
     763     * SMTP CODE SUCCESS: 450 ("%greylist%") 
     764     * SMTP CODE FAILURE: 550,551,552,553,450,451,452 
     765     * SMTP CODE ERROR  : 500,501,503,421 
     766     * @access public 
     767     * @return bool 
     768     */ 
     769    function CheckRecipient($to) { 
     770        $this->error = null; # so no confusion is caused 
     771 
     772        if(!$this->connected()) { 
     773            $this->error = array( 
     774                    "error" => "Called Recipient() without being connected"); 
     775            return false; 
     776        } 
     777 
     778        fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); 
     779 
     780        $rply = $this->get_lines(); 
     781        $code = substr($rply,0,3); 
     782 
     783        if($this->do_debug >= 2) { 
     784            echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; 
     785        } 
     786 
     787        // standard success codes 
     788        if($code == 250 || $code == 251) { 
     789            return true; 
     790        } 
     791 
     792        // ESMTP Postfix greylist filter 
     793        if($code == 450 && strpos(strtolower($reply), "greylisted")===false) { 
     794            return true; 
     795        } 
     796 
     797        $this->error = 
     798            array("error" => "RCPT not accepted from server", 
     799                  "smtp_code" => $code, 
     800                  "smtp_msg" => substr($rply,4)); 
     801        if($this->do_debug >= 1) { 
     802            echo "SMTP -> ERROR: " . $this->error["error"] . 
     803                     ": " . $rply . $this->CRLF; 
     804        } 
     805        return false; 
    752806    } 
    753807 
  • trunk/register.php

    r1401 r1413  
    9999                        $error .= sprintf($locale['413'], $email_domain)."<br /><br />\n"; 
    100100                    } else { 
    101                         if (!$mail->Recipient($email)) { 
     101                        if (!$mail->CheckRecipient($email)) { 
    102102                            // mail server doesn't respond to RCPT TO message 
    103103                            $error .= sprintf($locale['414'], $email, $mailhost)."<br /><br />\n"; 
Note: See TracChangeset for help on using the changeset viewer.