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依賴注入容器:快速啟動May 13, 2025 am 12:11 AM

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增強codemodocultion,可驗證性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

PHP中的依賴注入與服務定位器PHP中的依賴注入與服務定位器May 13, 2025 am 12:10 AM

選擇DependencyInjection(DI)用於大型應用,ServiceLocator適合小型項目或原型。 1)DI通過構造函數注入依賴,提高代碼的測試性和模塊化。 2)ServiceLocator通過中心註冊獲取服務,方便但可能導致代碼耦合度增加。

PHP性能優化策略。PHP性能優化策略。May 13, 2025 am 12:06 AM

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)啟用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替換loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

PHP電子郵件驗證:確保正確發送電子郵件PHP電子郵件驗證:確保正確發送電子郵件May 13, 2025 am 12:06 AM

phpemailvalidation invoLvesthreesteps:1)格式化進行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)

如何使PHP應用程序更快如何使PHP應用程序更快May 12, 2025 am 12:12 AM

tomakephpapplicationsfaster,關注台詞:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

PHP性能優化清單:立即提高速度PHP性能優化清單:立即提高速度May 12, 2025 am 12:07 AM

到ImprovephPapplicationspeed,關注台詞:1)啟用opcodeCachingwithapCutoredUcescriptexecutiontime.2)實現databasequerycachingingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandreduceconnection.4 limitesclection.4.4

PHP依賴注入:提高代碼可檢驗性PHP依賴注入:提高代碼可檢驗性May 12, 2025 am 12:03 AM

依赖注入(DI)通过显式传递依赖关系,显著提升了PHP代码的可测试性。1)DI解耦类与具体实现,使测试和维护更灵活。2)三种类型中,构造函数注入明确表达依赖,保持状态一致。3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

PHP性能優化:數據庫查詢優化PHP性能優化:數據庫查詢優化May 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

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脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

PhpStorm Mac 版本

PhpStorm Mac 版本

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

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具