PHP头条
热点:

smtp邮件发送一例


test_smtp.php(做为现在的主流开发语言)

<?
require("smtp.php(做为现在的主流开发语言)");

$smtp=new smtp_class;

$smtp->host_name="mail.xiaocui.com";
$smtp->localhost="localhost";
$from="webmaster@xiaocui.com";
$to="root@xiaocui.com";
if($smtp->SendMessage(
  $from,
  array(
   $to
  ),
  array(
   "From: $from",
   "To: $to",
   "Subject: Testing Manuel Lemos SMTP class"
  ),
  "Hello $to, It is just to let you know that your SMTP class is working just fine. Bye. "))
  echo "Message sent to $to OK. ";
else
  echo "Cound not send the message to $to. Error: ".$smtp->error." "
?>

smtp.php(做为现在的主流开发语言)

<?

class smtp_class
{
var $host_name="";
var $host_port=25;
var $localhost="";
var $timeout=0;
var $error="";
var $debug=1;
var $esmtp=1;
var $esmtp_host="";
var $esmtp_extensions=array();
var $maximum_piped_recipients=100;

/* private variables - DO NOT access(小型网站之最爱) */

var $state="Disconnected";
var $connection=0;
var $pending_recipients=0;

/* Private methods - DO NOT CALL */

Function OutputDebug($message)
{
  echo $message,"<br> ";
}

Function GetLine()
{
  for($line="";;)
  {
   if(feof($this->connection))
   {
    $this->error="reached the end of stream while reading from socket";
    return(0);
   }
   if(($data=fgets($this->connection,100))==false)
   {
    $this->error="it was not possible to read line from socket";
    return(0);
   }
   $line.=$data;
   $length=strlen($line);
   if($length>=2
   && substr($line,$length-2,2)==" ")
   {
    $line=substr($line,0,$length-2);
    if($this->debug)
     $this->OutputDebug("< $line");
    return($line);
   }
  }
}

Function PutLine($line)
{
  if($this->debug)
   $this->OutputDebug("> $line");
  if(!fputs($this->connection,"$line "))
  {
   $this->error="it was not possible to write line to socket";
   return(0);
  }
  return(1);
}

Function PutData($data)
{
  if(strlen($data))
  {
   if($this->debug)
    $this->OutputDebug("> $data");
   if(!fputs($this->connection,$data))
   {
    $this->error="it was not possible to write data to socket";
    return(0);
   }
  }
  return(1);
}

Function VerifyResultLines($code,$responses="")
{
  if(GetType($responses)!="array")
   $responses=array();
  Unset($match_code);

  while(($line=$this->GetLine($this->connection)))
  {

www.phpzy.comtrue/phprm/34634.htmlTechArticlesmtp邮件发送一例 test_smtp.php (做为现在的主流开发语言) ? require("smtp.php (做为现在的主流开发语言) "); smtp=new smtp_class; smtp-host_name="mail.xiaocui.com"; smtp-localhost="localhost"; from="webmaster@xiaocui...

相关文章

    暂无相关文章

PHP之友评论

今天推荐