通过socket发送smtp邮件,大部分邮件服务器是需要smtp验证的。
新建一个stmp_mail对象的时候,要指定服务器,帐号,密码等信息$host = "mail.yourdomain.com";
$port = "25";
$user = "[email protected]";
$pass = "123456";
//以上这些信息必须正确填写$smtp = smtp_mail($host,$port,$user,$pass)该类的构造函数也需要修改,如下。
function smtp_mail($host,$port,$user,$pass,$debug=false) 

$this->host = $host;
$this->port = $port;
$this->user = base64_encode($user); 
$this->pass = base64_encode($pass); 

解决方案 »

  1.   

    小弟学PHP不深,所以有些地方看不明白,
    那refresh.php里的
    <?
    //每刷新一次换一个mail地址
      $smtp = new smtp_mail;
      $smtp->send("test","mail地址","title","content");
    ?>send("test","mail地址","title","content");
    这个是不是也得改?**********************************************************************
    var $host; //主机 
    var $port; //端口 一般为25 
    var $user; //SMTP认证的帐号 
    var $pass; //认证密码 
    var $debug = false; //是否显示和服务器会话信息? 
    var $conn; 
    var $result_str; //结果 
    var $in; //客户机发送的命令 
    var $from; //源信箱 
    var $to; //目标信箱 
    var $subject; //主题 
    var $body; //内容 这些用改吗???
    ******************************************************************$host = "mail.yourdomain.com";
    $port = "25";
    $user = "[email protected]";
    $pass = "123456";这块我改了,但提示错误:
    Warning: Missing argument 1 for smtp_mail() in /www/smtp.php on line 16Warning: Missing argument 2 for smtp_mail() in /www/smtp.php on line 16Warning: Missing argument 3 for smtp_mail() in /www/smtp.php on line 16Warning: Missing argument 4 for smtp_mail() in /www/smtp.php on line 16Fatal error: Call to undefined function: socket_create() in /www/smtp.php on line 23就是这两行有问题:
    “function smtp_mail($host,$port,$user,$pass,$debug=false) ”
    “$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //具体用法请参考手册 ”咋办? 请高高手耐心讲讲 小弟就靠前辈们了!!先谢谢您
      

  2.   

    function smtp_mail($host,$port,$user,$pass,$debug=false)
    猜的:参数不对,function smtp_mail($host,$port,$user,$pass)
      

  3.   

    还一个问题:比如公司的邮件服务器是在“A”上,(A = 222.222.222.222) 那是不是得把这2个PHP放在A这个服务器上??那 $host = "222.222.222.222";  对吗???
      

  4.   

    refresh.php 修改成这样
    <?  $host = "mail.yourdomain.com";
      $port = "25";
      $user = "[email protected]";
      $pass = "123456";
      //以上这些信息要真实存在,并且mail.yourdoamin.com:25是对外开放的。
      
      $smtp = smtp_mail($host,$port,$user,$pass)
      $smtp->send("test","mail地址","title","content");
    ?>类的构造函数也需要修改,如下。
    function smtp_mail($host,$port,$user,$pass,$debug=false) 

    //改以下4行
    $this->host = $host;
    $this->port = $port;
    $this->user = base64_encode($user); 
    $this->pass = base64_encode($pass);
    ...
    }
      

  5.   

    在中<?
    //每刷新一次换一个mail地址
      $smtp = new smtp_mail;
      $smtp->send("test","mail地址","title","content");
    ?>每刷新一次换一个mail地址
    哪里的程序是实现刷新的?
      

  6.   

    johnpanq(飞花逐月) 老大,我照着您的改了,可现在提示解析错误:Parse error: parse error, unexpected T_VARIABLE in /www/test2/refresh.php on line 23也就是这行有问题:$smtp->send("test","[email protected]","title","content");哪错了?
      

  7.   

    23行的前一行少了个分号
    $smtp = smtp_mail($host,$port,$user,$pass);//这行加上个分号
    $smtp->send("test","[email protected]","title","content");
      

  8.   

    - -||分号是加上了。可又卡在这里了。高手您往下看↓Warning: Missing argument 1 for smtp_mail() in /www/smtp.php on line 16Warning: Missing argument 2 for smtp_mail() in /www/smtp.php on line 16Warning: Missing argument 3 for smtp_mail() in /www/smtp.php on line 16Warning: Missing argument 4 for smtp_mail() in /www/smtp.php on line 16Fatal error: Call to undefined function: socket_create() in /www/smtp.php on line 23就是这两行有问题:
    16行:“function smtp_mail($host,$port,$user,$pass,$debug=false) ”
    23行:“$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //具体用法请参考手册 ”不太明白怎么调试,前辈们请指点讲讲啊!!!!谢谢了!!!!!!!!!!!!
      

  9.   

    16行:“function smtp_mail($host,$port,$user,$pass,$debug=false) ”
    23行:“$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //具体用法请参考手册 ”卡在这里了!!怎么办啊!!555555
      

  10.   

    - -!!通了 。是服务器PHP下的socket的扩展没有安装。按了就OK了 - -////感谢楼上所有大哥大姐!!谢谢了
      

  11.   


    又有问题了!
    1)调是调通了,可使这两个程序不能给外界的EMAIL发啊,比如SINA,126,(使本公司的邮件服务器)2)我以前使mail()函数发邮件,通过fopen()打开带有EMAIL地址的TXT文本(格式如下)。
    [email protected]
    [email protected]
    [email protected]
    这样就能陆续发送,可使上面的程序只能发一条(而且接到邮件的内容还是这样,如下),回车后的发送不了啊?!为啥?“Subject:EMAIL标题
    X-Priority: 3
    X-MSMail-Priority: Normal
    Content-Transfer-Encoding: 8bit
    MIME-Version: 1.0
    Date: Wed, 13 Sep 2006 14:38:19 +0800
    X-Mailer:By Redhat (PHP/4.3.8)
    Message-ID: <[email protected]>
    Content-Type: text/html
    X-Brightmail-Tracker: AAAAAQAAAAQ=
    Resent-Message-Id: <44714DA9.04DBDB.21903>
    Resent-Date: Wed, 13 Sep 2006 14:38:19 +0800
    EMAIL内容”这都写的啥?看不明白啊?!急急!!
      

  12.   

    如何实现群批发送邮件啊??比如:我把N多的EMAIL地址放在一个文本文件里格式如下:[email protected]
    [email protected]
    [email protected]
    ...上面的程序是不是得相应修改?改哪里?谢谢高手啊 !!!
      

  13.   

    以上问题都解决了,现在有个问题,如何分辨发送成功和不成功?
    我吧debug打开 显示信息,其中:
    发送成功会显示:Recipient ok 
    发送错误会显示:Relaying denied. Proper authentication required. 但我想统计出发送成功多少条,发送失败多少条,都有哪些(明细)这个要怎么做啊?高手们帮帮忙~~~~
      

  14.   

    while1228(111111111111111111111) 大哥您能说的详细些吗?  - - 3q~~
      

  15.   

    急啊!!发送内容里写超链接的HTML代码,比如:<a href="www.sina.com">123</a>
    但收到邮件,一看地址这样:
    /"www.sina.com\"
    再点击后弹出IE窗口,可IE窗口地址栏是如下内容:
    res://shdoclc/syntax.htm#\"www.sina.com\"这是为什么啊?!