选择语言 :

 Core_Email::_send_command

Send SMTP command

string Core_Email::_send_command( string $cmd [, string $data = empty ] )

参数列表

参数 类型 描述 默认值
$cmd string
$data string empty
返回值
  • string
File: ./core/classes/email.class.php
protected function _send_command($cmd, $data = '')
{
    switch ($cmd)
    {
        case 'hello' :
            if ($this->_smtp_auth || $this->_get_encoding() === '8bit')
            {
                $this->_send_data('EHLO '.$this->_get_hostname());
            }
            else
            {
                $this->_send_data('HELO '.$this->_get_hostname());
            }

            $resp = 250;
        break;
        case 'starttls'  :

            $this->_send_data('STARTTLS');
            $resp = 220;
        break;
        case 'from' :

            $this->_send_data('MAIL FROM:<'.$data.'>');
            $resp = 250;
        break;
        case 'to' :

            if ($this->dsn)
            {
                $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
            }
            else
            {
                $this->_send_data('RCPT TO:<'.$data.'>');
            }

            $resp = 250;
        break;
        case 'data'    :

            $this->_send_data('DATA');
            $resp = 354;
        break;
        case 'quit'    :

            $this->_send_data('QUIT');
            $resp = 221;
        break;
    }

    $reply = $this->_get_smtp_data();

    $this->_debug_msg[] = '<pre>'.$cmd.': '.$reply.'</pre>';

    if ( (int) substr($reply, 0, 3) !== $resp)
    {
        $this->_set_error_message('lang:email_smtp_error', $reply);
        return false;
    }

    if ($cmd === 'quit')
    {
        fclose($this->_smtp_connect);
    }

    return true;
}