protected function sendCommandSecurity($command, $code)
{
try {
if (fwrite($this->_socket, $command)) {
//当邮件内容分多次发送时,没有$code,服务器没有返回
if (empty($code)) {
return true;
}
//读取服务器返回
$data = trim(fread($this->_socket, 1024));
if ($data) {
$pattern = "/^" . $code . "+?/";
if (preg_match($pattern, $data)) {
return true;
} else {
$this->_errorMessage = "Error:" . $data . "|**| command:";
return false;
}
} else {
return false;
}
} else {
$this->_errorMessage = "Error: " . $command . " send failed";
return false;
}
} catch (Exception $e) {
$this->_errorMessage = "Error:" . $e->getMessage();
}
}