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

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

php中文網(wǎng)
發(fā)布: 2016-07-25 08:45:29
原創(chuàng)
1342人瀏覽過
  1. /***********************************************************************************
  2. 使用說明:
  3. $m= new SendM('smtp服務(wù)器地址','賬號','密碼',端口(int),超時重試時間(int));
  4. $m->Send('收件人郵箱 ','主題','郵件正文內(nèi)容');
  5. 使用范例:
  6. $m= new SendM('smtp.yeah.net','testuser','testuserpwd',25,30);
  7. $m->Send('a@coolmr.com ','測試郵件','這是一封郵件發(fā)送類的測試郵件,謝謝您的支持');
  8. *************************************************************************************/
  9. class SendM{
  10. private $Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout,$ms,$ending = "\r\n",$endingc="\n";
  11. function __construct($Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout){
  12. $this->Mailhost=$Mailhost;
  13. $this->Mailuser=$Mailuser;
  14. $this->Mailpwd=$Mailpwd;
  15. $this->Mailport=$Mailport;
  16. $this->Mailtimeout=$Mailtimeout;
  17. $this->ConnectSmtpServer();
  18. }
  19. private function ConnectSmtpServer(){
  20. if(!is_string($this->Mailhost)){ settype(trim($this->Mailhost),"string"); }
  21. if(!is_integer($this->Mailport)){ settype(trim($this->Mailport),"integer"); }
  22. if(!is_integer($this->Mailtimeout)){ settype(trim($this->Mailtimeout),"integer"); }
  23. $this->ms=@fsockopen($this->Mailhost,$this->Mailport,$this->errorno,$this->errorstr,$this->Mailtimeout);
  24. if(substr(PHP_OS,0,3) != "WIN"){ stream_set_timeout($this->ms, $this->Mailtimeout, 0);}
  25. $rcp = $this->get_echo();
  26. fputs($this->ms,"ehlo bobo".$this->ending);
  27. $rcp = $this->get_echo();
  28. if(substr($rcp,0,3)!='250'){ return false; }
  29. fputs($this->ms,'auth login'.$this->ending);
  30. $rcp = $this->get_echo();
  31. if(substr($rcp,0,3)=='334'){ $this->Auth($this->Mailuser,$this->Mailpwd); }else{ return false; } }
  32. private function Auth($Mailuser,$Mailpwd){
  33. $this->Mailuseren=base64_encode($Mailuser); $this->Mailpwden=base64_encode($Mailpwd);
  34. fputs($this->ms,$this->Mailuseren.$this->ending);
  35. $rcp = $this->get_echo();
  36. fputs($this->ms,$this->Mailpwden.$this->ending);
  37. $rcp = $this->get_echo(); }
  38. private function get_echo(){
  39. $edata=""; while($estr=@fgets($this->ms,600)){ $edata .= $estr;
  40. if(substr($estr,3,1) == " ") { break; } }
  41. return $edata; }
  42. public function Send($to,$subject,$connect){
  43. $host=explode('.',$this->Mailhost);
  44. $fromaddress=$this->Mailuser.'@'.$host[1].'.'.$host[2];
  45. fputs($this->ms,'mail from:'.$this->ending);
  46. $rcp = $this->get_echo();
  47. fputs($this->ms,'rcpt to:'.$this->ending);
  48. $rcp = $this->get_echo();
  49. fputs($this->ms,'data'.$this->ending);
  50. $rcp = $this->get_echo();
  51. fputs($this->ms,"to:$to".$this->endingc);
  52. fputs($this->ms,"from:$fromaddress".$this->endingc);
  53. fputs($this->ms,"subject:$subject".$this->endingc.$this->endingc);
  54. fputs($this->ms,"$connect".$this->endingc);
  55. fputs($this->ms,'.'.$this->ending);
  56. $rcp = $this->get_echo(); if(substr($rcp,0,3)=='250'){header("Location:main_pro.php?act=msg&errors=on&msg=郵件發(fā)送成功!已成功提交至對方服務(wù)器!"); }else{ header("Location:main_pro.php?act=msg&errors=on&msg=很遺憾,郵件發(fā)送失敗了!請檢查郵件賬戶配置是否正確!"); }
  57. }
  58. }
  59. ?>
復(fù)制代碼

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


PHP速學(xué)教程(入門到精通)
PHP速學(xué)教程(入門到精通)

PHP怎么學(xué)習(xí)?PHP怎么入門?PHP在哪學(xué)?PHP怎么學(xué)才快?不用擔(dān)心,這里為大家提供了PHP速學(xué)教程(入門到精通),有需要的小伙伴保存下載就能學(xué)習(xí)啦!

下載
來源:php中文網(wǎng)
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請聯(lián)系admin@php.cn
最新問題
開源免費(fèi)商場系統(tǒng)廣告
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
關(guān)于我們 免責(zé)申明 意見反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓(xùn),幫助PHP學(xué)習(xí)者快速成長!
關(guān)注服務(wù)號 技術(shù)交流群
PHP中文網(wǎng)訂閱號
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時隨地碎片化學(xué)習(xí)
PHP中文網(wǎng)抖音號
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://m.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號