sm.php<?phpclass smtp{/* Public Variables */var $smtp_port;var $time_out;var $host_name;var $log_file;var $relay_host;var $debug;var $auth;var $user;v......
if (!($this->sock && $this->smtp_ok())) { $this->log_write("Warning: Cannot connect to mx host ".$host."\n"); $this->log_write("Error: ".$errstr." (".$errno.")\n"); continue; } $this->log_write("Connected to mx host ".$host."\n"); return TRUE; } $this->log_write("Error: Cannot connect to any mx hosts (".implode(", ", $MXHOSTS).")\n"); return FALSE; }
function smtp_message($header, $body) { fputs($this->sock, $header."\r\n".$body); $this->smtp_debug(">; ".str_replace("\r\n", "\n".">; ", $header."\n>; ".$body."\n>; "));
return TRUE; }
function smtp_eom() { fputs($this->sock, "\r\n.\r\n"); $this->smtp_debug(". [EOM]\n");
return $this->smtp_ok(); }
function smtp_ok() { $response = str_replace("\r\n", "", fgets($this->sock, 512)); $this->smtp_debug($response."\n");
if (!ereg("^[23]", $response)) { fputs($this->sock, "QUIT\r\n"); fgets($this->sock, 512); $this->log_write("Error: Remote host returned \"".$response."\"\n"); return FALSE; } return TRUE; }
function smtp_putcmd($cmd, $arg = "") { if ($arg != "") { if($cmd=="") $cmd = $arg; else $cmd = $cmd." ".$arg; }
fputs($this->sock, $cmd."\r\n"); $this->smtp_debug(">; ".$cmd."\n");
return $this->smtp_ok(); }
function smtp_error($string) { $this->log_write("Error: Error occurred while ".$string.".\n"); return FALSE; }
function log_write($message) { $this->smtp_debug($message);
if ($this->log_file == "") { return TRUE; }
$message = date("M d H:i:s ").get_current_user()."[".getmypid()."]: ".$message; if (log_file">!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) { $this->smtp_debug("Warning: Cannot open log file \"".$this->log_file."\"\n"); return FALSE; } flock($fp, LOCK_EX); fputs($fp, $message); fclose($fp);
return TRUE; }
function strip_comment($address) { $comment = "\\([^()]*\\)"; while (ereg($comment, $address)) { $address = ereg_replace($comment, "", $address); }
return $address; }
function get_address($address) { $address = ereg_replace("([ \t\r\n]) ", "", $address); $address = ereg_replace("^.*<(. )>;.*$", "\\1", $address);
3/4 首页 上一页 1 2 3 4 下一页 尾页 |