<?php class SendM{ private $Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout,$ms,$ending = "\r\n",$endingc="\n"; function __construct($Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout){ $this->Mailhost=$Mailhost; $this->Mailuser=$Mailuser; $this->Mailpwd=$Mailpwd; $this->Mailport=$Mailport; $this->Mailtimeout=$Mailtimeout; $this->ConnectSmtpServer(); } private function ConnectSmtpServer(){ if(!is_string($this->Mailhost)){ settype(trim($this->Mailhost),"string"); } if(!is_integer($this->Mailport)){ settype(trim($this->Mailport),"integer"); } if(!is_integer($this->Mailtimeout)){ settype(trim($this->Mailtimeout),"integer"); } $this->ms=@fsockopen($this->Mailhost,$this->Mailport,$this->errorno,$this->errorstr,$this->Mailtimeout); if(substr(PHP_OS,0,3) != "WIN"){ stream_set_timeout($this->ms, $this->Mailtimeout, 0);} $rcp = $this->get_echo(); fputs($this->ms,"ehlo bobo".$this->ending); $rcp = $this->get_echo(); if(substr($rcp,0,3)!='250'){ return false; } fputs($this->ms,'auth login'.$this->ending); $rcp = $this->get_echo(); if(substr($rcp,0,3)=='334'){ $this->Auth($this->Mailuser,$this->Mailpwd); }else{ return false; } } private function Auth($Mailuser,$Mailpwd){ $this->Mailuseren=base64_encode($Mailuser); $this->Mailpwden=base64_encode($Mailpwd); fputs($this->ms,$this->Mailuseren.$this->ending); $rcp = $this->get_echo(); fputs($this->ms,$this->Mailpwden.$this->ending); $rcp = $this->get_echo(); } private function get_echo(){ $edata=""; while($estr=@fgets($this->ms,600)){ $edata .= $estr; if(substr($estr,3,1) == " ") { break; } } return $edata; } public function Send($to,$subject,$connect){ $host=explode('.',$this->Mailhost); $fromaddress=$this->Mailuser.'@'.$host[1].'.'.$host[2]; fputs($this->ms,'mail from:<'.$fromaddress.'>'.$this->ending); $rcp = $this->get_echo(); fputs($this->ms,'rcpt to:<'.$to.'>'.$this->ending); $rcp = $this->get_echo(); fputs($this->ms,'data'.$this->ending); $rcp = $this->get_echo(); fputs($this->ms,"to:$to".$this->endingc); fputs($this->ms,"from:$fromaddress".$this->endingc); fputs($this->ms,"subject:$subject".$this->endingc.$this->endingc); fputs($this->ms,"$connect".$this->endingc); fputs($this->ms,'.'.$this->ending); $rcp = $this->get_echo(); if(substr($rcp,0,3)=='250'){header("Location:main_pro.php?act=msg&errors=on&msg=郵件發(fā)送成功!已成功提交至對(duì)方服務(wù)器!"); }else{ header("Location:main_pro.php?act=msg&errors=on&msg=很遺憾,郵件發(fā)送失敗了!請(qǐng)檢查郵件賬戶配置是否正確!"); } } } ?>
これはメール送信用の php クラスです。必要な友達(dá)はダウンロードして使用してください。
使用説明:
$m= new SendM('smtp サーバー アドレス', 'アカウント', 'パスワード', ポート (int), タイムアウト再試行時(shí)間 (int));
$m->Send('受信者のメール', '件名', 'メール本文');
使用例:
$m= new SendM ('smtp .yeah.net','testuser','testuserpwd',25,30);
$m->Send('a@coolmr.com ','テストメール','これはメール送信用のテストメールです。ご支援ありがとうございます');
このサイトのすべてのリソースはネチズンによって提供されたもの、または主要なダウンロード サイトによって転載されたものです。ソフトウェアの整合性をご自身で確認(rèn)してください。このサイトのすべてのリソースは學(xué)習(xí)の參考のみを目的としています。商業(yè)目的で使用しないでください。そうでない場(chǎng)合は、すべての結(jié)果に対して責(zé)任を負(fù)うことになります。侵害がある場(chǎng)合は、削除するためにご連絡(luò)ください。連絡(luò)先情報(bào): admin@php.cn
関連記事

08 May 2025
bestpracticesforsendingemails securlyinphpinclude:1)sutureconsmttarttlsencryptionとの使用の使用、2)検証およびサンシジン化のinputStopReventinjectuctacks、3)adinitivedinitivedInemailsopenslsl、4)adlinglinglingemailoaに

28 Aug 2025
Pythonを使用して電子メールを自動(dòng)的に送信するには、最初にSMTPを構(gòu)成し、電子メールを送信するスクリプトを書き込む必要があります。特定の手順は次のとおりです。1。smtplibと電子メールライブラリを使用してSMTP接続をセットアップし、Gmailおよびその他のメールボックスのSMTPサーバー(smtp.gmail.comなど)を介して電子メールを送信します。 TLSの暗號(hào)化を有効にし、アプリケーション固有のパスワードでログインする必要があります。 2. mimemultipartメッセージオブジェクトを作成し、送信者、受信者、トピックを設(shè)定し、mimetextでプレーンテキストまたはHTMLコンテンツを追加します。 HTMLメールは、スタイルをサポートするためにコンテンツタイプを「HTML」に設(shè)定する必要があります。 3.マイムベースとエンコーダーを介してファイルを添付します。

21 Apr 2025
ジャムスタックスタイルのサイト(使用中のサーバー側(cè)の言語はありません)を揺らしていると言いましょうが、メールを送信するようなダイナミックなことをしたいと思います。ではありません

09 May 2025
PHPとSMTPを使用してメールを送信することは、PHPMailerライブラリを介して実現(xiàn)できます。 1)PHPMailerをインストールして構(gòu)成する、2)SMTPサーバーの詳細(xì)を設(shè)定する、3)電子メールコンテンツを定義し、4)メールを送信してエラーを処理します。この方法を使用して、電子メールの信頼性とセキュリティを確保します。

22 Jul 2025
tosendanemailwithanattachmentinphpusingthemail()function、yourmust hundlemimeencodingbuybuildingamultipartmessage、ecodingtheattachmentinbase64、およびsettingthecorrectheaders.1.ensureyourserserversveriscon figuntososedemaindethatementthmentmentmentmentmentmentmentmentionedimmentfifileisefileisedimedimedimedementhain

16 May 2025
はい、itispossibletosendmassemailswithphp.1)uselibrarieslikephpmailerorsforfienceemailsending.2)vetseemailstoavoidspamflags.3)emorizeemailsusingdynamicconttoimbroveengagemention.


ホットツール Tags

ホットツール

50 個(gè)の優(yōu)れた古典的な PHP アルゴリズムのコレクション
古典的な PHP アルゴリズム、優(yōu)れたアイデアを?qū)Wび、思考を広げます

依存関係注入コンテナー用の PHP ライブラリ
依存関係注入コンテナー用の PHP ライブラリ

畫像を最適化するための小さな PHP ライブラリ
畫像を最適化するための小さな PHP ライブラリ
