php邮箱发送类代码
发布:smiling 来源: PHP粉丝网 添加日期:2014-01-22 21:13:49 浏览: 评论:0
下面是一款婚恋网站的邮箱发送实例代码,有需要的朋友可以下载
- <?php
- //if ($err) {echo "发送邮件失败,原因:<br>";foreach($err as $a){echo $a."<br>";}}
- class wrzc_netmail {
- /* var $localhost;
- var $smtp_accname;
- var $smtp_password;
- var $smtp_host;
- var $from;
- var $fromname;
- */ function send($to, $subject = 'no subject', $body) {
- $localhost = $this->localhost;
- $smtp_accname = $this->smtp_accname;
- $smtp_password = $this->smtp_password;
- $smtp_host = $this->smtp_host;
- $from = $this->from;
- $fromname = $this->fromname;
- $lb = "rn";
- $headers = "content-type: text/html;charset="gbk"";
- $headers.= $lb;
- $headers.= "content-transfer-encoding: base64";
- $hdr = explode($lb, $headers);
- if ($body) {
- $bdy = preg_replace("/^./", "..", explode($lb, $body));}
- $smtp[] = array("ehlo ".$localhost.$lb, "220,250", "ehlo error: ");
- $smtp[] = array("auth login".$lb, "334", "auth error: ");
- $smtp[] = array(base64_encode($smtp_accname).$lb, "334", "authentification error: ");
- $smtp[] = array(base64_encode($smtp_password).$lb, "235", "authentification error: ");
- $smtp[] = array("mail from: <".$from.">".$lb, "250", "mail from error: ");
- $smtp[] = array("rcpt to: <".$to.">".$lb, "250", "rcpt to error: ");
- $smtp[] = array("data".$lb, "354", "data error: ");
- $smtp[] = array("from: ".$fromname." <".$from.">".$lb, "", "");
- $smtp[] = array("subject: ".$subject.$lb, "", "");
- $smtp[] = array("to: ".$to.$lb, "", "");
- foreach ($hdr as $h) {
- $smtp[] = array($h.$lb, "", "");}
- $smtp[] = array($lb, "", "");
- if ($bdy) {
- foreach ($bdy as $b) {
- $smtp[] = array(base64_encode($b.$lb).$lb, "", "");}}
- $smtp[] = array(".".$lb, "250", "data(end)error: ");
- $smtp[] = array("quit".$lb, "221", "quit error: ");
- $fp = @fsockopen($smtp_host, 25);
- if (!$fp)
- return "error: cannot conect to '".$smtp_host."' by port 25";
- while ($result = @fgets($fp, 1024)) {
- if (substr($result, 3, 1) == " ") {
- break;}}
- $result_str;
- foreach ($smtp as $req) {
- @fputs($fp, $req[0]);
- if ($req[1]) {
- while ($result = @fgets($fp, 1024)) {
- if (substr($result, 3, 1) == " ") {
- break;}};
- if (!strstr($req[1], substr($result, 0, 3))) {
- $result_str[] = $req[2].$result;}}}
- @fclose($fp);
- return $result_str;}
- function setlocalhost($localhost) {$this->localhost = $localhost;}
- function setsmtp_accname($smtp_accname) {$this->smtp_accname = $smtp_accname;}
- function setsmtp_password($smtp_password) {$this->smtp_password = $smtp_password;}
- function setsmtp_host($smtp_host) {$this->smtp_host = $smtp_host;}
- function setfrom($from) {$this->from = $from;}
- function setfromname($fromname) {$this->fromname = $fromname;}
- }
- //unset
- ?>
Tags: php 邮箱 发送代码
- 上一篇:PHP发邮件函数实现代码
- 下一篇:利用php mail()进行邮件发送实现方法
相关文章
- ·PHP 是什么?(2013-11-12)
- ·Php.ini文件位置在哪里 Php.ini文件找不到(2013-11-12)
- ·PHP 数据类型(2013-11-12)
- ·php 获取当前脚本的url(2013-11-12)
- ·php技术生成静态页面的实现(2013-11-13)
- ·缺陷月项目启动 披露PHP脚本语言漏洞(2013-11-13)
- ·在PHP中全面阻止SQL注入式攻击(2013-11-13)
- ·php生成随机密码的几种方法(2013-11-13)
- ·PHP中使用FCKeditor2.3.2配置(2013-11-13)
- ·如何使用PHP开发高效的WEB系统(2013-11-13)
- ·php:树形结构的算法(2013-11-13)
- ·php4和php5区别(2013-11-13)
- ·php数据库连接(2013-11-13)
- ·如何正确理解PHP的错误信息(2013-11-13)
- ·php页面漏洞分析及相关问题解决(2013-11-13)
- ·当在连接PHP时,抱怨一些数值没有定义参考?(2013-11-27)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)