PHP的一个完整SMTP类(解决邮件服务器需要验证时的问题)

时间:2010-01-18 08:58:10   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:br />     var $time_out;      var $host_name;      var $log_file;      var $relay_host;      var $debug;      var $auth;      var $user;
  正文:

smtp.PHP
  
  <?php
  class smtp
  
  {
  
  /* Public Variables */
  
  var $smtp_port;
  
  var $time_out;
  
  var $host_name;
  
  var $log_file;
  
  var $relay_host;
  
  var $debug;
  
  var $auth;
  
  var $user;
  
  var $pass;
  
  /* Private Variables */
  var $sock;
  
  /* Constractor */
  
  function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
  
  {
  
  $this->debug = FALSE;
  
  $this->smtp_port = $smtp_port;
  
  $this->relay_host = $relay_host;
  
  $this->time_out = 30; //is used in fsockopen()
  #
  
  $this->auth = $auth;//auth
  
  $this->user = $user;
  
  $this->pass = $pass;
  
  #
  
  $this->host_name = "localhost"; //is used in HELO command
  $this->log_file = "";
  
  
  
  $this->sock = FALSE;
  
  }
  
  /* Main Function */
  
  function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
  
  {
  
  $mail_from = $this->get_address($this->strip_comment($from));
  
  $body = ereg_replace("(^|(rn))(.)", "1.3", $body);
  
  $header .= "MIME-Version:1.0rn";
  
  if($mailtype=="HTML"){
  
  $header .= "Content-Type:text/htmlrn";
  
  }
  
  $header .= "To: ".$to."rn";
  
  if ($cc != "") {
  
  $header .= "Cc: ".$cc."rn";
  
  }
  
  $header .= "From: $from<".$from.">rn";
  
  $header .= "Subject: ".$subject."rn";
  
  $header .= $additional_headers;
  
  $header .= "Date: ".date("r")."rn";
  
  $header .= "X-Mailer:By Redhat (PHP/".phpversion().")rn";
  
  list($msec, $sec) = explode(" ", microtime());
  
  $header .= "Message-ID: <".date("YmdHis", $sec).".".($msec*1000000).".".$mail_from.">rn";
  
  $TO = explode(",", $this->strip_comment($to));
  
  if ($cc != "") {
  
  $TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
  
  }
  
  if ($bcc != "") {
  
来源:http://www.002pc.com/master/College/Programming/PHP/11986.html

 1/5    1 2 3 4 5 下一页 尾页
收藏到:

关于《PHP的一个完整SMTP类(解决邮件服务器需要验证时的问题)》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td