微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php邮箱发送类代码

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

  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.$lb220,250ehlo error: ); 
  25.  $smtp[] = array(auth login.$lb334auth error: ); 
  26.  $smtp[] = array(base64_encode($smtp_accname).$lbauthentification error: ); 
  27.  $smtp[] = array(base64_encode($smtp_password).$lb235authentification error: ); 
  28.  $smtp[] = array(mail from: <.$from.>.$lb250mail from error: ); 
  29.  $smtp[] = array(rcpt to: <.$to.>.$lbrcpt to error: ); 
  30.  $smtp[] = array(data.$lb354data 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(..$lbdata(end)error: ); 
  41.  $smtp[] = array(quit.$lb221quit 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, 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. //unset 
  66. ?> 

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐