最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > 建站教程 > php教程 >

php邮箱发送类代码

时间:2014-06-09 16:40来源: 作者: 点击: 次
下面是一款婚恋网站的邮箱发送实例代码,有需要的朋友可以下载 ?php //if($err){echo发送邮件失败,原因:br;foreach($erras$a){echo$a.br;}} class wrzc_netmail{ /*var$localhost; var$smtp_accname; var$smtp_password; var$sm

下面是一款婚恋网站的邮箱发送实例代码,有需要的朋友可以下载

  1. <?php 
  2. //if ($err) {echo "发送邮件失败,原因:<br>";foreach($err as $a){echo $a."<br>";}} 
  3. class wrzc_netmail { 
  4. /*  var $localhost; 
  5.  var $smtp_accname; 
  6.  var $smtp_password; 
  7.  var $smtp_host; 
  8.  var $from; 
  9.  var $fromname; 
  10.  */ function send($to, $subject = 'no subject', $body) { 
  11.  $localhost = $this->localhost; 
  12.  $smtp_accname = $this->smtp_accname; 
  13.  $smtp_password = $this->smtp_password; 
  14.  $smtp_host = $this->smtp_host; 
  15.  $from = $this->from; 
  16.  $fromname = $this->fromname; 
  17.  $lb = "rn"; 
  18.  $headers = "content-type: text/html;charset="gbk""; 
  19.  $headers.= $lb; 
  20.  $headers.= "content-transfer-encoding: base64"; 
  21.  $hdr = explode($lb, $headers); 
  22.  if ($body) { 
  23.  $bdy = preg_replace("/^./", "..", explode($lb, $body));} 
  24.  $smtp[] = array("ehlo ".$localhost.$lb, "220,250", "ehlo error: "); 
  25.  $smtp[] = array("auth login".$lb, "334", "auth error: "); 
  26.  $smtp[] = array(base64_encode($smtp_accname).$lb, "334", "authentification error: "); 
  27.  $smtp[] = array(base64_encode($smtp_password).$lb, "235", "authentification error: "); 
  28.  $smtp[] = array("mail from: <".$from.">".$lb, "250", "mail from error: "); 
  29.  $smtp[] = array("rcpt to: <".$to.">".$lb, "250", "rcpt to error: "); 
  30.  $smtp[] = array("data".$lb, "354", "data error: "); 
  31.  $smtp[] = array("from: ".$fromname." <".$from.">".$lb, "", ""); 
  32.  $smtp[] = array("subject: ".$subject.$lb, "", ""); 
  33.  $smtp[] = array("to: ".$to.$lb, "", ""); 
  34.  foreach ($hdr as $h) { 
  35.  $smtp[] = array($h.$lb, "", "");} 
  36.  $smtp[] = array($lb, "", ""); 
  37.  if ($bdy) { 
  38.  foreach ($bdy as $b) { 
  39.  $smtp[] = array(base64_encode($b.$lb).$lb, "", "");}} 
  40.  $smtp[] = array(".".$lb, "250", "data(end)error: "); 
  41.  $smtp[] = array("quit".$lb, "221", "quit error: "); 
  42.  $fp = @fsockopen($smtp_host, 25); 
  43.  if (!$fp) 
  44.  return "error: cannot conect to '".$smtp_host."' by port 25"; 
  45.  while ($result = @fgets($fp, 1024)) { 
  46.  if (substr($result, 3, 1) == " ") { 
  47.  break;}} 
  48.  $result_str; 
  49.  foreach ($smtp as $req) { 
  50.  @fputs($fp, $req[0]); 
  51.  if ($req[1]) { 
  52.  while ($result = @fgets($fp, 1024)) { 
  53.  if (substr($result, 3, 1) == " ") { 
  54.  break;}}; 
  55.  if (!strstr($req[1], substr($result, 0, 3))) { 
  56.  $result_str[] = $req[2].$result;}}} 
  57.  @fclose($fp); 
  58.  return $result_str;} 
  59.  function setlocalhost($localhost) {$this->localhost = $localhost;} 
  60.  function setsmtp_accname($smtp_accname) {$this->smtp_accname = $smtp_accname;} 
  61.  function setsmtp_password($smtp_password) {$this->smtp_password = $smtp_password;} 
  62.  function setsmtp_host($smtp_host) {$this->smtp_host = $smtp_host;} 
  63.  function setfrom($from) {$this->from = $from;} 
  64.  function setfromname($fromname) {$this->fromname = $fromname;} 
  65. } 
  66. //unset 
  67. ?> 

 

(责任编辑:admin)
------分隔线----------------------------
栏目列表
推荐内容