SlightPHP\SMTP::Recipient PHP Method

Recipient() public method

Returns true if the recipient was accepted false if it was rejected. Implements from rfc 821: RCPT TO: SMTP CODE SUCCESS: 250,251 SMTP CODE FAILURE: 550,551,552,553,450,451,452 SMTP CODE ERROR : 500,501,503,421
public Recipient ( $to ) : boolean
return boolean
    public function Recipient($to)
    {
        $this->error = null;
        // so no confusion is caused
        if (!$this->connected()) {
            $this->error = array("error" => "Called Recipient() without being connected");
            return false;
        }
        fputs($this->smtp_conn, "RCPT TO:<" . $to . ">" . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply, 0, 3);
        if ($this->do_debug >= 2) {
            echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
        }
        if ($code != 250 && $code != 251) {
            $this->error = array("error" => "RCPT not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply, 4));
            if ($this->do_debug >= 1) {
                echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
            }
            return false;
        }
        return true;
    }