彼女は私の罪です gtp smtp メール送信例
test_smtp.php
以上、彼女は私の罪です gtp smtp 邮件送信一例を含み、彼女は私の罪です gtp の側面の内容を含み、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",
"件名: Manuel Lemos の SMTP クラスのテスト"
),
"Hello $to,nnこれは、SMTP クラスが次のとおりであることをお知らせするためのものです。正常に動作しています。nnBye.n"))
echo "$to OK.n にメッセージを送信しました。";
else
echo "$to.n にメッセージを送信できませんでした。エラー: ".$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";
}
関数 GetLine()
{
for($line="";;)
{
if(feof($this->connection))
{
$this->error="到達ソケットからの読み取り中のストリームの終わり";
return(0);
}
if(($data=fgets($this->connection,100))==false)
{
$this->error ="ソケットから行を読み取ることができませんでした";
return(0);
}
$line.=$data;
$length=strlen($line);
if($length>=2
&& substr ($line,$length-2,2)=="rn")
{
$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,"$linern"))
{
$this->error="ソケットに行を書き込むことができませんでした";
return(0);
}
return(1);
}
関数 PutData($data)
{
if(strlen($data))
{
if($this->debug)
$this->OutputDebug("> ; $data");
if(!fputs($this->connection,$data))
{
$this->error="ソケットにデータを書き込むことができませんでした";
return(0) ;
}
}
return(1);
}
Function VerifyResultLines($code,$resp>{
if(GetType($responses)!="array")
$resp> Unset($match_code);
while (($line=$this->GetLine($this->connection)))
{
if(IsSet($match_code))
{
if(strcmp(strtok($line," -"),$ match_code)))
{
$this->error=$line;
return(0);
}
}
else
{
$match_code=strtok($line," -");
if(GetType($ code)=="array")
{
for($codes=0;$codes
{
$this->error=$line;
return(0);
}
}
else
{
if(strcmp($match_code,$code))
{
$this->error=$line;
return(0);
}
}
}
$responses[]=strtok(" ");
if(!strcmp($match_code,strtok($line," ")))
return(1);
}
return(-1);
}
Function FlushRecipients()
{
if($ this->pending_sender)
{
if($this->VerifyResultLines("250") return(0);
$this->pending_sender=0;
}
for(;$ this->pending_recipients;$this->pending_recipients--)
{
if($this->VerifyResultLines(array("250","251"))<=0)
return(0);
}
return(1);
}
/* パブリック メソッド */
Function Connect()
{
$this->error=$error="";
$this->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($error)
{
case -3:
$this->error="-3 ソケットを作成できませんでした" ;
return(0);
case -4:
$this->error="-4 ホスト名 "".$host_name." の DNS ルックアップに失敗しました";
return(0);
case -5:
$this->error="-5 接続が拒否されたかタイムアウトしました";
return(0);
case -6:
$this->error="-6 fdopen() 呼び出しが失敗しました";
return(0 );
case -7:
$this->error="-7 setvbuf() call failed";
return(0);
default:
$this->error=$error." に接続できませんでした。ホスト "".$this->host_name.""";
return(0);
}
}
else
{
if(!strcmp($localhost=$this->localhost,"")
&& !strcmp($localhost=getenv("SERVER_NAME"),"")
&& !strcmp($localhost=getenv("HOST"),""))
$localhost="localhost";
$success=0;
if($this->VerifyResultLines("220")>0)
{
if($this->esmtp)
{
$resp> if($this->PutLine("EHLO $localhost" )
&& $this->VerifyResultLines("250",&$responses)>0)
{
$this->esmtp_host=strtok($responses[0]," ");
for($resp> {
$extension=strtoupper(strtok($responses[$response]," "));
$this->esmtp_extensions[$extension]=strtok("");
$success=1;
}
}
if(!$success
&& $this->PutLine("HELO $localhost")
&& $this->VerifyResultLines("250")>0)
$success=1;
}
if( $success)
{
$this->state="接続済み";
return(1);
}
else
{
fclose($this->connection);
$this->c> $this->state="切断されました";
return(0);
}
}
}
関数 MailFrom( $sender)
{
if(strcmp($this->state,"接続済み"))
{
$this->error="接続が初期状態ではありません";
return(0);
}
$this->error="";
if(!$this->PutLine("MAIL FROM: <".$sender.">"))
return(0);
if(!IsSet ($this->esmtp_extensions["PIPELINING"])
&& $this->VerifyResultLines("250")<=0)
return(0);
$this->state="SenderSet";
if(IsSet($this->esmtp_extensions["PIPELINING"]))
$this->pending_sender=1;
$this->pending_recipients=0;
return(1);
}
Function SetRecipient($受信者)
{
switch($this->state)
{
case "SenderSet":
case "RecipientSet":
break;
default:
$this->error="接続が受信者の設定にありませんstate";
return(0);
}
$this->error="";
if(!$this->PutLine("RCPT TO:<".$recipient.">"))
return(0);
if(IsSet($this->esmtp_extensions["PIPELINING"]))
{
$this->pending_recipients++;
if($this->pending_recipients>=$this-> Maximum_piped_recipients)
{
if(!$this->FlushRecipients())
return(0);
}
}
else
{
if($this->>VerifyResultLines(array("250", 「251」 ))<=0)
return(0);
}
$this->state="RecipientSet";
return(1);
}
Function StartData()
{
if(strcmp($this- >state,"RecipientSet"))
{
$this->error="接続はデータ送信開始状態ではありません";
return(0);
}
$this->error="";
if(!$this->PutLine("DATA"))
return(0);
if($this->pending_recipients)
{
if(!$this->FlushRecipients())
return( 0);
}
if($this->VerifyResultLines("354")<=0)
return(0);
$this->state="SendingData";
return(1);
}
関数 PrepareData($data,&$output)
{
$length=strlen(&$data);
for($output="",$position=0;$position<$length;)
{
$next_position =$length;
for($current=$position;$current<$length;$current++)
{
switch($data[$current])
{
case "n":
$next_position=$current+1 ;
break 2;
case "r":
$next_position=$current+1;
if($data[$next_position]=="n")
$next_position++;
break 2;
}
}
if( $data[$position]==".")
$output.=".";
$output.=substr(&$data,$position,$current-$position)."rn";
$position= $next_position;
}
}
Function SendData($data)
{
if(strcmp($this->state,"SendingData"))
{
$this->error="接続が送信中にありませんデータ状態";
return(0);
}
$this->error="";
return($this->PutData(&$data));
}
関数 EndSendingData()
{
if(strcmp($this->state,"SendingData"))
{
$this->error="接続はデータ送信状態ではありません";
return(0) ;
}
$this->error="";
if(!$this->PutLine("rn.")
|| $this->VerifyResultLines("250")<=0)
return(0);
$this->state="接続済み";
return(1);
}
Function ResetConnection()
{
switch($this->state)
{
case "接続済み":
return(1);
case "SendingData":
$this->error="データ送信中に接続をリセットできません";
return(0);
case "Disconnected":
$this->error ="確立される前に接続をリセットすることはできません";
return(0);
}
$this->error="";
if(!$this->PutLine("RSET")
|| $this->VerifyResultLines("250")<=0)
return(0);
$this->state="接続済み";
return(1);
}
Function Disconnect($quit=1) )
{
if(!strcmp($this->state,"切断"))
{
$this->error="以前に SMTP 接続が確立されていませんでした";
return(0);
}
$this->error="";
if(!strcmp($this->state,"接続済み")
&& $quit
&& (!$this->PutLine("QUIT")
|| $this->VerifyResultLines("221")<=0))
return(0);
fclose($this->connection);
$this->c> $this->state="切断されました";
return(1);
}
関数 SendMessage($sender,$recipients,$headers,$body)
{
if(($success=$this->Connect()))
{
if (($success=$this->MailFrom($sender)))
{
for($recipient=0;$recipient
if(!($success=$) this->SetRecipient($recipients[$recipient])))
break;
}
if($success
&& ($success=$this->StartData()))
{
for($header_data=" ",$header=0;$header
if(($success=$this->SendData($ header_data."rn")))
{
$this->PrepareData($body,&$body_data);
$success=$this->SendData($body_data);
}
if($success)
$success=$this->EndSendingData();
}
}
$disc> if($success)
$success=$disconnect_success;
}
return($success);
}
};
?>

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









セッションハイジャックは、次の手順で達成できます。1。セッションIDを取得します。2。セッションIDを使用します。3。セッションをアクティブに保ちます。 PHPでのセッションハイジャックを防ぐための方法には次のものが含まれます。1。セッション_regenerate_id()関数を使用して、セッションIDを再生します。2。データベースを介してストアセッションデータを3。

JWTは、JSONに基づくオープン標準であり、主にアイデンティティ認証と情報交換のために、当事者間で情報を安全に送信するために使用されます。 1。JWTは、ヘッダー、ペイロード、署名の3つの部分で構成されています。 2。JWTの実用的な原則には、JWTの生成、JWTの検証、ペイロードの解析という3つのステップが含まれます。 3. PHPでの認証にJWTを使用する場合、JWTを生成および検証でき、ユーザーの役割と許可情報を高度な使用に含めることができます。 4.一般的なエラーには、署名検証障害、トークンの有効期限、およびペイロードが大きくなります。デバッグスキルには、デバッグツールの使用とロギングが含まれます。 5.パフォーマンスの最適化とベストプラクティスには、適切な署名アルゴリズムの使用、有効期間を合理的に設定することが含まれます。

PHP開発における固体原理の適用には、次のものが含まれます。1。単一責任原則(SRP):各クラスは1つの機能のみを担当します。 2。オープンおよびクローズ原理(OCP):変更は、変更ではなく拡張によって達成されます。 3。Lischの代替原則(LSP):サブクラスは、プログラムの精度に影響を与えることなく、基本クラスを置き換えることができます。 4。インターフェイス分離原理(ISP):依存関係や未使用の方法を避けるために、細粒インターフェイスを使用します。 5。依存関係の反転原理(DIP):高レベルのモジュールと低レベルのモジュールは抽象化に依存し、依存関係噴射を通じて実装されます。

システムが再起動した後、UnixSocketの権限を自動的に設定する方法。システムが再起動するたびに、UnixSocketの許可を変更するために次のコマンドを実行する必要があります:sudo ...

phpstormでCLIモードをデバッグする方法は? PHPStormで開発するときは、PHPをコマンドラインインターフェイス(CLI)モードでデバッグする必要がある場合があります。

静的結合(静的::) PHPで後期静的結合(LSB)を実装し、クラスを定義するのではなく、静的コンテキストで呼び出しクラスを参照できるようにします。 1)解析プロセスは実行時に実行されます。2)継承関係のコールクラスを検索します。3)パフォーマンスオーバーヘッドをもたらす可能性があります。

PHP開発でPHPのCurlライブラリを使用してJSONデータを送信すると、外部APIと対話する必要があることがよくあります。一般的な方法の1つは、Curlライブラリを使用して投稿を送信することです。
