喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
 18  1/2  1  2  > 
     
标题: 不跟你们玩了,发一个老的smtp类  
 
sadly (sadly)
管理员
Rank: 9Rank: 9Rank: 9
管理员


UID 1
精华 4
积分 2043
帖子 2032
金钱 1544 喜悦币
威望 40
人脉 459
阅读权限 200
注册 1970-1-1
来自 北京 三元桥
状态 离线
[广告]: q m
不跟你们玩了,发一个老的smtp类



<?  
/*
 * Smtp sender class
 * Author:    Goodyork
 * Version:    1.0.0
 * Website: [url]www.phpx.com[/url]
 * Modifications:
 *        2002-11-16   initial modified by goodyork
 *
*/
class smtp_sender
{  
    var 
$host
    var 
$port
    var 
$user
    var 
$pass
    var 
$debug false
    var 
$conn;  
    var 
$result_str;
    var 
$in
    var 
$from
    var 
$to
    var 
$subject
    var 
$body
    var 
$socket;
    
    function 
smtp_sender($debug=false)
    {
           
$this->smtp_ori('smtp服务器地址','smtp端口','用户名','密码',$debug);
    }
    function 
smtp_ori($host,$port,$user,$pass,$debug=false)  
    {  
        
$this->host   $host;   
        
$this->port   $port;   
        
$this->user   base64_encode($user);   
        
$this->pass   base64_encode($pass);   
        
$this->debug  $debug;   
        
$this->socket fsockopen($this->host,$this->port$errno$errstr30);
        
        if (!
$this->socket
         {
           die(
"error:$errstr ($errno)<br />n");
         } 
     }   
    function 
debug_show($str)   
    {   
         if(
$this->debug==true)   
         {   
            echo 
$str."<br>rn";   
         }   
    }   
    function 
send($from,$to,$subject,$body,$mailtype="html",$fromname="默认显示的发件人名字")   
    {   
         if(
$from == "" || $to == "")   
         {   
            exit(
"you must enter email address");   
         }   

         if(
$subject == ""$sebject "no subject";   
         if(
$body    == ""$body    "no content";   
         
$body str_replace("n""rn"$body);
         
$body str_replace("rr""r"$body);         
         
$this->from     =  $from;   
         
$this->to      =  $to;   
         
$this->subject  =  $subject;   
         
$this->body     =  $body;   

         
$All           "From: $fromname<".$this->from.">rn";   
         
$All          .= "To: ".$this->to."rn";   
         
$All          .= "Subject: ".$this->subject."rn";   
         
$All                   .= "MIME-Version: 1.0rn";
     if(
strtolower($mailtype)=="html")  
         
$All                  .="Content-Type: text/html;charset=\"gb2312\"rn";
         
$All                   .= "Date: ".date("r")."rn";
         
$All                   .= "X-Mailer: Microsoft Outlook Express 5.50.4522.1200rn";
     list(
$msec$sec) = explode(" "microtime());
         
$All                   .= "Message-ID: <".date("YmdHis"$sec).".".($msec*1000000).".".$from.">rnrn";
         
$All          .= $this->body;   
        
         
$this->in       =  "EHLO HELOrn";   
         
$this->sendcommand();   
         
$this->in       =  "AUTH LOGINrn";   
         
$this->sendcommand();   
         
$this->in       =  $this->user."rn";   
         
$this->sendcommand();   
         
$this->in       =  $this->pass."rn";   
         
$this->sendcommand();   
         
$this->in       =  "MAIL FROM:".$this->from."rn";   
         
$this->sendcommand();   
         
$this->in       =  "RCPT TO:".$this->to."rn";   
         
$this->sendcommand();   
         
$this->in       =  "DATArn";   
         
$this->sendcommand();   
         
$this->in       =  $All."rn.rn";;            
         
$this->sendcommand();   
         
$this->in       =  "QUITrn";   
         
$this->sendcommand();   
     
    }   
    function 
sendcommand()   
    {   
        
fwrite($this->socket$this->in);   
        
$this->debug_show("Command:".$this->in);   
        
$this->result_str "Response:".fread ($this->socket1024)."";   
        
$this->debug_show($this->result_str);   
    }   

//following is a sample  ,注意事项:发送html格式邮件时,message需要做nl2br
/*
    $mail_title="喜悦国际村密码提醒邮件";
    $message  = "t喜悦国际村密码提醒邮件!rnrn";
    $message .= "t您的用户名是:".$UserName."rnrn";
    $message .= "t您的密码是:".$Password."rnrn";
    $message .= "t<a href=\"http://www.phpx.com/">喜悦国际村  PHP因你而精彩</a>rnrn";
    $smtpsender=new smtp_sender(true);
    $smtpsender->send("发件人email","收件人email",$mail_title,nl2br($message),"html");  
*/
?>




以PHP在中国的繁荣发展为己任
QQ:824008 MSN:sadly@phpx.com
2005-12-29 11:56 AM#1
查看资料  访问主页  Blog  发短消息  QQ  ICQ 状态  顶部
 
wleige (一天到晚游泳的鱼)
高级会员
Rank: 4
中级会员


UID 64348
精华 0
积分 682
帖子 680
金钱 682 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2005-5-25
来自 周口人在上海
状态 离线
[推荐阅读] 上传头像
村长送出的东东一定要收下的



有勇气来改变可以改变的事情,有胸怀来接受不可改变的事情,有智慧来分辨两者的不同。http://www.featuredbride.com
2005-12-29 12:01 PM#2
查看资料  访问主页  Blog  发短消息  QQ  顶部
 
lgy1
中级会员
Rank: 3Rank: 3
一般会员



UID 67096
精华 0
积分 201
帖子 175
金钱 201 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2005-10-4
状态 离线
[推荐阅读] 怎样写mysql 正则
好,要了.



...
2005-12-29 12:10 PM#3
查看资料  发短消息  顶部
 
duketang (duketang)
版主
Rank: 7Rank: 7Rank: 7
无聊的老亮


UID 18398
精华 3
积分 84
帖子 1646
金钱 54 喜悦币
威望 30
人脉 0
阅读权限 100
注册 2003-2-17
来自 沈阳->北京->沈阳-> ...
状态 离线
[推荐阅读] 请问怎么得到返回的cookies?
顶?



Msn:duketxl@gmail.com
OICQ:8339544
www.80666.cn
性搜
中国招标信息数据库
2005-12-29 12:10 PM#4
查看资料  Blog  发短消息  QQ  顶部
 
shelly0577 (shelly0577)
金牌会员
Rank: 6Rank: 6
高级会员


UID 18493
精华 0
积分 1733
帖子 1736
金钱 1709 喜悦币
威望 0
人脉 24
阅读权限 70
注册 2003-2-21
状态 离线
[推荐阅读] 有关在线广告效率问题~请进
有没有支持NTLM方式登陆的?
2005-12-29 12:28 PM#5
查看资料  访问主页  Blog  发短消息  顶部
 
onalps
中级会员
Rank: 3Rank: 3
一般会员



UID 63212
精华 0
积分 313
帖子 229
金钱 313 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2005-2-17
状态 离线
[推荐阅读] 请教这个效果怎么做?上次一个高手发表过的……
报告村长.
Command:EHLO HELO
Response:220 smtp125.sohu.com ESMTP
Command:AUTH LOGIN
Response:250-smtp125.sohu.com 250-PIPELINING 250-SIZE 10485760 250-ETRN 250-AUTH LOGIN 250 8BITMIME
Command:ZmxveWQ=
Response:334 VXNlcm5hbWU6
Command:bGkybGl1
Response:334 UGFzc3dvcmQ6
Command:MAIL FROM:floyd@sohu.com
Response:
Command:RCPT TO:floyd@sohu.com
Response:
CommandATA
Response:
Command:From: 默认显示的发件人名字 To: floyd@sohu.com Subject: 喜悦国际村密码提醒邮件 MIME-Version: 1.0 Content-Type: text/html;charset="gb2312" Date: Thu, 29 Dec 2005 12:50:22 +0800 X-Mailer: Microsoft Outlook Express 5.50.4522.1200 Message-ID: <20051229125022.935835.floyd@sohu.com> 喜悦国际村密码提醒邮件!

PHP因你而精彩

.
Response:
CommandUIT
Response:

这样为什么还没收到呢?
2005-12-29 12:46 PM#6
查看资料  发短消息  顶部
 
buzzard (家有咸妻)
高级会员
Rank: 4
老不死的会员


UID 19416
精华 0
积分 866
帖子 1137
金钱 866 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2003-4-7
状态 离线
[推荐阅读] 初学oop,问一个非常简单的问题...
最近村长频频露脸,有大事发生?
2005-12-29 01:36 PM#7
查看资料  发短消息  顶部
 
梅君
注册会员
Rank: 2
中级会员


UID 63847
精华 0
积分 134
帖子 149
金钱 134 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-3-30
来自 北京
状态 离线
[推荐阅读] 问个关于mysql的问题
这个好像不可以带附件 或 发html 格式的吧  (没有试过 说错了不要怪我)
2005-12-29 02:14 PM#8
查看资料  访问主页  发短消息  QQ  顶部
 
sadly (sadly)
管理员
Rank: 9Rank: 9Rank: 9
管理员


UID 1
精华 4
积分 2043
帖子 2032
金钱 1544 喜悦币
威望 40
人脉 459
阅读权限 200
注册 1970-1-1
来自 北京 三元桥
状态 离线
[推荐阅读] 问个mysql的问题,急啊!!


QUOTE:
最初由 梅君 发布
[B]这个好像不可以带附件 或 发html 格式的吧  (没有试过 说错了不要怪我) [/B]
一般的html可以. multipart的不行(带附件的就属于multipart的哦~~)




以PHP在中国的繁荣发展为己任
QQ:824008 MSN:sadly@phpx.com
2005-12-29 02:38 PM#9
查看资料  访问主页  Blog  发短消息  QQ  ICQ 状态  顶部
 
梅君
注册会员
Rank: 2
中级会员


UID 63847
精华 0
积分 134
帖子 149
金钱 134 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-3-30
来自 北京
状态 离线
[推荐阅读] 大家回复的时候都是什么想的?
还是习惯用自己的 虽然没有那么严紧 但是功能还是都可以的 ^_^
2005-12-29 03:36 PM#10
查看资料  访问主页  发短消息  QQ  顶部
 18  1/2  1  2  > 
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.056687 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP