国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁(yè) PHP 函式庫(kù) 其它類別庫(kù) 發(fā)送電子郵件的php類
發(fā)送電子郵件的php類
<?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)檢查郵件賬戶配置是否正確!"); }
  }
}
?>

這是一個(gè)發(fā)送電子郵件的php類,需要的朋友可以下載使用。

使用說(shuō)明:

$m= new SendM('smtp伺服器位址','帳號(hào)','密碼',連接埠(int),逾時(shí)重試時(shí)間(int));

$m->Send('收件者信箱','主題','郵件正文內(nèi)容');

使用範(fàn)例:

$m= new SendM ('smtp.yeah.net','testuser','testuserpwd',25,30);

$m->Send('a@coolmr.com ','測(cè)試郵件','這是一封郵件發(fā)送類別的測(cè)試郵件,謝謝您的支援');

免責(zé)聲明

本站所有資源皆由網(wǎng)友貢獻(xiàn)或各大下載網(wǎng)站轉(zhuǎn)載。請(qǐng)自行檢查軟體的完整性!本站所有資源僅供學(xué)習(xí)參考。請(qǐng)不要將它們用於商業(yè)目的。否則,一切後果都由您負(fù)責(zé)!如有侵權(quán),請(qǐng)聯(lián)絡(luò)我們刪除。聯(lián)絡(luò)方式:admin@php.cn

相關(guān)文章

PHP發(fā)送電子郵件類 PHP發(fā)送電子郵件類

25 Jul 2016

PHP發(fā)送電子郵件類

發(fā)送帶有PHP的電子郵件 發(fā)送帶有PHP的電子郵件

02 Mar 2025

核心要點(diǎn) PHP 提供了一種簡(jiǎn)單有效的方法來(lái)發(fā)送電子郵件,包括基本的純文本郵件、HTML 郵件和帶有附件的郵件。 PHP 的 mail() 函數(shù)用於發(fā)送電子郵件。對(duì)於簡(jiǎn)單的郵件,它只需要三個(gè)參數(shù):收件人的地址、主題和郵件正文。 發(fā)送 HTML 郵件或帶有附件的郵件時(shí),需要使用 MIME 標(biāo)準(zhǔn)將郵件分解成多個(gè)部分,並用選定的邊界分隔。每個(gè)部分都應(yīng)定義內(nèi)容是什麼、如何編碼、可能的內(nèi)容處置方式,以及內(nèi)容本身。 使用 PHPMailer 庫(kù)可以增強(qiáng) PHP 發(fā)送郵件的功能,該庫(kù)允許連接 SMTP 服務(wù)

PHP電子郵件教程:發(fā)送電子郵件很容易 PHP電子郵件教程:發(fā)送電子郵件很容易

19 May 2025

sendingemailswithphpisstraightforwardusingthemail()functionormoreAdvancedLibrariesLikeLikePhpMailer.1)usemail()forbasicemails,settreCipients,settrecipients,subjects,message,messages,messages和headeers.2)forhtmlemails,juspeStheadeStheadeStheadeSteStospeSpepeSpepeSpepeCifyHtmlconteN.3)

PHP電子郵件安全性:發(fā)送電子郵件的最佳實(shí)踐 PHP電子郵件安全性:發(fā)送電子郵件的最佳實(shí)踐

08 May 2025

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

PHP電子郵件驗(yàn)證:確保正確發(fā)送電子郵件 PHP電子郵件驗(yàn)證:確保正確發(fā)送電子郵件

13 May 2025

phpemailvalidation invoLvesthreesteps:1)格式化進(jìn)行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)

如何解決 PHP Mail() 和 PHPMailer 的電子郵件傳送問(wèn)題? 如何解決 PHP Mail() 和 PHPMailer 的電子郵件傳送問(wèn)題?

22 Oct 2024

本文提供了使用 PHP mail() 或 PHPMailer 發(fā)送電子郵件時(shí)遇到的問(wèn)題的偵錯(cuò)解決方案。它解決了與 mail() 函數(shù)和缺少 PHPMailer 類別導(dǎo)入相關(guān)的錯(cuò)誤。文章建議啟用 SMTP debuggin

See all articles