host_name="mail.xiaocui.com "; $smtp->localhost="localhost";$from="webmaster@xiaocui.com";$to="root@xiaocui.com";if($smtp->發送"/> host_name="mail.xiaocui.com "; $smtp->localhost="localhost";$from="webmaster@xiaocui.com";$to="root@xiaocui.com";if($smtp->發送">
搜尋
首頁後端開發php教程she is my sin gtp smtp郵件發送一例

test_smtp.php

require("smtp.php");
$smtp=new smtp_class;
$smtp->host_name="mail.xiaocui.com";
$$smtp->host_name="mail.xiaocui.com";
$$ smtp->localhost="localhost";
$from="webmaster@xiaocui.com";
$to="root@xiaocui.com";
if($smtp->; SendMessage(
  $from,
  array(
   $to
  ),
  array(
  🎜 >   「主題:測試Manuel Lemos 的SMTP 類別」
  ),
  「Hello $to,nn這只是為了讓您知道您的SMTP 類別運作良好。nnBye.n」))
echo "訊息已寄至$to OK.n";
else
  echo "無法將訊息傳送至$to.nError: ".$smtp->error."n"
?>
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_extensi >var $maximum_piped_recipients=100;
/* 私有變數- 請勿存取*/
var $state="Disconnected";
var $c>var $pending_recipients=0;
/ * 私有方法- 請勿呼叫*/
Function OutputDebug($message)
{
  echo $message,"
n";
}
Function GetLine()
{
{
{ 🎜>  for($line="";;)
  {
   if(feof($this->connection))
   {    return(0);
   }
   if(($data=fgets($this->connection,100))==false)
{
{
    $this->error="無法從套接字讀取行";
    return(0);
   }
   $line.=$$mmmo> );
   if($length>=2
   && substr($line,$length-2,2)=="rn")
   {
  ,$length-2);
    if($this->debug)
     $this->OutputDebug("   return($eturn($line); >  }
}
函數PutLine($line)
{
  if($this->debug )
   $this->OutputDebug("> $line")
   $this->OutputDebug("> $line");  $this->OutputDebug("> $line"); (!fputs($this->connection,"$linern"))
  {
   $this- >error="無法將行寫入套接字";
   return(0);
  }
  return(1);
}
函數PutData($data)
{
  if(strlen($data))
 this {debug)
    $this->OutputDebug("> $data");
   if(!fputs($this->connection,$data))
   {
"無法將資料寫入套接字";
    return(0) ;
   }
  }
  return(1);
}

{
  if(GetType($responses)!="array")
   $resp>  Unset($match_code);
  while(($line=$this->Get);
  while(($line=$this->Get);
  while(($line=$this->Getconection($this-connection )))
  {
   if(IsSet($match_code) ))
   {
    if(strcmp >     $this->error=$line;
     return(0 $line," -");
    if(GetType($code)=="array")
    {
     for($codes=0;$codes     if($codes>=count ($code))
     {
      }
    }
    其他
    {
     if(strcmp($match_code,$code))
     return(0);
}
    }
   }
   $responses[]=strtok("");
   if(!strcmp($match_code,strtok(> ;
  }
  return(-1);
}
函數FlushRecipients()
{
  if($ this->VerifyResultLines("250")    return(0);
   $this->pending_sender=0;
  }pending_recipients--)
  {
   if($this->VerifyResultLines(array("250","251"))  >  return(1);
}
/* 公共方法*/
Function Connect()
{
  $this->error=$ error="";
  ->esmtp_host="";
   $this->esmtp_extensi>  if(!($this->c ? fsockopen($this->host_name,$this ->host_port,&$errno,&$error,$this ->timeout) : fsockopen($this->host_name,$this->host_port))))
  {
   switch($錯誤)
    🠎>this switch($錯誤)
    ->error=" 能夠創建-3 SDK";
     return(0);
    case -4:
     $this->error="-4 主機名稱"".上_name.$的dns 尋找失敗";
     return(0);
    case -5:
     $ >    case -6:
     $this->error="-6 fdopen() 呼叫失敗";
     return (0);     return(0);
    預設值:
     $this- >error=$error." 無法連線至主機數"name.$ ";
     return(0);
   }
  }
  else
  {
thisofm-host&Pm

   && !strcmp( $localhost=getenv("HOST"),""))
  $success=0;
    if($this->VerifyResultLines("220")> p> if( $this->PutLine("EHLO $localhost")
      && $this->VerifyResultLines("250",&$responses)>0)
      {
       $this->esmtp_host=strtok( $responses [0]," ");
       for($resp> {
        $extension=strtoupper(strtok($res ension ]=strtok("");
       }
$success=1;
      }
   ->PutLine("HELO $localhost ")
     && $this->VerifyResultLines(" 250")>0)
      $success=1; state="已連接";
    return( 1);
   }
   else
   {
    fclose($this->connection);
    $this->c> }
  }
}
函數MailFrom($sender)
{
  if(strcmp($this->state,"已連結")) ->error="連線未處於初始狀態";
   return(0);
  }
  $this->error="";
  if(!$ this->PutLine("郵件寄件者:"))
   return(0);
  if(!IsSet($this->esmtp_extensions["PIPELINING"] )
  && $this-> VerifyResultLines("250")   return(0);
  $this->state="SenderSet";
  if(IsSet( $this->esmtp_extensions[🎜>  if(IsSet( $this->esmtp_extensions["PIPEING"])
   $this->pending_sender=1;
  $this->pending_recipients=0;
  return(1);
}
函數SetRecipipf> switch($this->state)
  {
   case "SenderSet":
   case "RecipientSet":
   處於接收者設定狀態";
    return(0);
  }
  $this->error="";
  if(!$this->PutLine("RCPT TO:"))
   return(0);
  if(IsSet($this->") esmtp_extensions["PIPELINING"]))
  {   if($this->pending_recipients>=$this->maximum_piped_recipients)
   {
    if }
  }
  else
  {
   if($this->VerifyResultLines(array(") 250","251")) > 🎜>  $this->state="RecipientSet";
  return(1);
}
函數StartData()
{
  if(strcmp($this->state,"RecipientSet "))
  {
   $this->error="連線不在開始傳送資料狀態";
   return(0);
  }
  $-0);
  }
  $-> 🎜>  if(!$this->PutLine("DATA"))
   return(0);
  if($this->pending_recipients)
 this { ())
    return(0);
}
  if($this->VerifyResultLines("354")   return(0);
  ="SendingData";
  return(1 );
}
函數PrepareData($data,&$output)
{
  $length=strlen(&$data); for($output="",$position= 0;$position  {
   $next_position=$length;
   for($current=$position=$length;
   for($current=$position=$length;
  th for($current=$position;$current   {
    switch ($data[$current])
    {
        break 2;
     case "r":
      case "r":
      $next_position =$current+1;
      if($data[    break 2;
    }
   }
   if($data [$position]==".")
    $output.=".";
   $output.=substr(&$currentdata,$position,$current -$position)."rn";
   $position=$next_position;
  }
}
函數SendData($data)
{
this
thiso> state,"SendingData"))
{
   $this->error="連接未處於發送數據狀態";
   return(0);
  }
  $this->error= "";
return($this->PutData(&$data));
}
Function EndSendingData()
{
  if(strcmp($this->state,"SendingData"))
  {
   $this->error="連線不在正在傳送資料狀態" ;
   return(0);
  }
  $this->error="";
  if(!$this->PutLine("rn.")
  if(!$this->PutLine("rn.")
  if(!$this->PutLine("rn.")
  if >VerifyResultLines("250")   return(0);
  $this->state="已連接";
  return(1);
}
}
函數ResetConnectionConnection ()
{
  switch($this->state)
  {
   case "Connected":
    return(1);thiserror="傳送資料時無法重設連線";
    return(0);
   case "Disconnected":
    $this->error ="在建立連線之前無法重設連線連線」;
    return(0);
  }
  $this->error="";
  if(!$this->PutLine ("RSET")   return(0);
  $this->state="已連接";
  return(1);
}
函數斷開連接($quit=1)
{
  if(!strcmp($this->state,"Disconnected"))
  {
   $this->error="之前未建立SMTP 連線";
   return(0);
  }
  $this->error="";
  if( !strcmp($this->state,"已連接")
 if( !strcmp($this->state,"已連接")
 & $quit
  && (!$this->PutLine("QUIT")
  || $this->VerifyResultLines("221")   return(0)
;
   return(0)
;
; ->connection);
  $this->c>  $this ->state="Disconnected";
  return(1);
}
函數SendMessage($sender,$recipients,$headers ,$body)
{
  if(($ success=$this->Connect()))
  {
   if(($success=$this->MailFrom($sender)))
   {
    for($recipient=0 ;$recipient    {
.$58885( recipients])))
      break;
    }
    if($success
     for($header_data= "",$header=0;$header      $header_data.=$headers[$header]."rn";
   >SendData($header_data."rn") ))
     {
      $this->PrepareData($body,&$body_data);
this 🎜>     }
     if( $success)
      $success=$this->EndSendingData ); if($success)
    $success= $disconnect_success;
  }
  return($success);
}
};
?>

以上就介紹了she is my sin gtp smtp郵件發送一例,包括she is my sin gtp方面的內容,希望對PHP教程有興趣的朋友有所幫助。

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
繼續使用PHP:耐力的原因繼續使用PHP:耐力的原因Apr 19, 2025 am 12:23 AM

PHP仍然流行的原因是其易用性、靈活性和強大的生態系統。 1)易用性和簡單語法使其成為初學者的首選。 2)與web開發緊密結合,處理HTTP請求和數據庫交互出色。 3)龐大的生態系統提供了豐富的工具和庫。 4)活躍的社區和開源性質使其適應新需求和技術趨勢。

PHP和Python:探索他們的相似性和差異PHP和Python:探索他們的相似性和差異Apr 19, 2025 am 12:21 AM

PHP和Python都是高層次的編程語言,廣泛應用於Web開發、數據處理和自動化任務。 1.PHP常用於構建動態網站和內容管理系統,而Python常用於構建Web框架和數據科學。 2.PHP使用echo輸出內容,Python使用print。 3.兩者都支持面向對象編程,但語法和關鍵字不同。 4.PHP支持弱類型轉換,Python則更嚴格。 5.PHP性能優化包括使用OPcache和異步編程,Python則使用cProfile和異步編程。

PHP和Python:解釋了不同的範例PHP和Python:解釋了不同的範例Apr 18, 2025 am 12:26 AM

PHP主要是過程式編程,但也支持面向對象編程(OOP);Python支持多種範式,包括OOP、函數式和過程式編程。 PHP適合web開發,Python適用於多種應用,如數據分析和機器學習。

PHP和Python:深入了解他們的歷史PHP和Python:深入了解他們的歷史Apr 18, 2025 am 12:25 AM

PHP起源於1994年,由RasmusLerdorf開發,最初用於跟踪網站訪問者,逐漸演變為服務器端腳本語言,廣泛應用於網頁開發。 Python由GuidovanRossum於1980年代末開發,1991年首次發布,強調代碼可讀性和簡潔性,適用於科學計算、數據分析等領域。

在PHP和Python之間進行選擇:指南在PHP和Python之間進行選擇:指南Apr 18, 2025 am 12:24 AM

PHP適合網頁開發和快速原型開發,Python適用於數據科學和機器學習。 1.PHP用於動態網頁開發,語法簡單,適合快速開發。 2.Python語法簡潔,適用於多領域,庫生態系統強大。

PHP和框架:現代化語言PHP和框架:現代化語言Apr 18, 2025 am 12:14 AM

PHP在現代化進程中仍然重要,因為它支持大量網站和應用,並通過框架適應開發需求。 1.PHP7提升了性能並引入了新功能。 2.現代框架如Laravel、Symfony和CodeIgniter簡化開發,提高代碼質量。 3.性能優化和最佳實踐進一步提升應用效率。

PHP的影響:網絡開發及以後PHP的影響:網絡開發及以後Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP類型提示如何起作用,包括標量類型,返回類型,聯合類型和無效類型?PHP類型提示如何起作用,包括標量類型,返回類型,聯合類型和無效類型?Apr 17, 2025 am 12:25 AM

PHP類型提示提升代碼質量和可讀性。 1)標量類型提示:自PHP7.0起,允許在函數參數中指定基本數據類型,如int、float等。 2)返回類型提示:確保函數返回值類型的一致性。 3)聯合類型提示:自PHP8.0起,允許在函數參數或返回值中指定多個類型。 4)可空類型提示:允許包含null值,處理可能返回空值的函數。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。