由于phpmailer的sendmail部分依赖popen打开sendmail发信,而popen在文件不存在的情况下也返回一个句柄,所以,这是个很大的bug.

修改了sendmail.cf......Cweqhi.com  依旧被126拒收。
改用smtp,由于本地sendmail是开着的,而telnet上去可以正常发信。所以。
修改phpmailer发送类型为smtp, smtp host为 localhost.由于本地没有设置密码验证,所以。其他都为空。
发信成功。126,yahoo.
发信失败。eqhi.com
如果不设置sender.那么sender将被替换为apache@localhost.如果用sendmail方式,则sender将被替换为from的值.
设置了sender=bailing.那么return-path:bailing@localhost

test_smtp.php

 

<?php
$INCLUDE_DIR = "../";

require_once("echo.php");
require("phpunit.php");
require($INCLUDE_DIR . "class.phpmailer.php");
error_reporting(E_ALL);

$newMail = new PHPMailer();

$newMail->Priority = 3;
$newMail->Encoding = "8bit";
$newMail->CharSet = "utf-8";
$newMail->From = "alamutu@sf.net";
$newMail->FromName = "smtp bailing Tester";
$newMail->Sender = "bailing";
$newMail->Subject = "smtp Unit Test";
$newMail->Body = "smtp test";
$newMail->AltBody = "";
$newMail->WordWrap = 0;
$newMail->Host = 'localhost';
$newMail->Port = 25;
$newMail->Helo = "sf.net";
$newMail->SMTPAuth = false;
$newMail->Username = "";
$newMail->Password = "";
$newMail->PluginDir = $INCLUDE_DIR;
$newMail->to[] = array("base5@126.com" , "126 bailing" );
$newMail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy");
$newMail->Sender = "bailing@sf.net";

$newMail->IsSMTP();
$r=$newMail->Send();
if (!$r) {
    
echo $newMail->ErrorInfo;
}
echo $newMail->ErrorInfo;
?>

test_sendmail.php

<?php
$INCLUDE_DIR = "../";

require_once("echo.php");
require("phpunit.php");
require($INCLUDE_DIR . "class.phpmailer.php");
error_reporting(E_ALL);

$newMail = new PHPMailer();

$newMail->Priority = 3;
$newMail->Encoding = "8bit";
$newMail->CharSet = "utf-8";
$newMail->From = "baxxx#eqhi.com";
$newMail->FromName = "bailing Tester";
$newMail->Sender = "";
//$newMail->to[] = array("baxxdd#126.com" , "tobailing" );
$newMail->to[] = array("baxxdd#126.com" , "126 bailing" );
$newMail->Subject = "3-9-bailing Test sendmail";
$newMail->Body = "hello";
$newMail->AltBody = "hl alt";
$newMail->WordWrap = 0;
$newMail->Helo = "eqhi.com";
$newMail->Username = "";
$newMail->Password = "";
$newMail->PluginDir = $INCLUDE_DIR;

$newMail->Sendmail = '/usr/sbin/sendmail'
$newMail->isSendmail();

if(!$newMail->Send()){
    
echo $newMail->ErrorInfo;
}
echo $newMail->ErrorInfo;

?>

test_mail.php.系统自带的邮件函数。

<?php
$INCLUDE_DIR = "../";

require_once("echo.php");
require("phpunit.php");
require($INCLUDE_DIR . "class.phpmailer.php");
error_reporting(E_ALL);

$newMail = new PHPMailer();

$newMail->Priority = 3;
$newMail->Encoding = "8bit";
$newMail->CharSet = "utf-8";
$newMail->From = "baxxdd@eqhi.com";
$newMail->FromName = "bailing Tester";
$newMail->Sender = "";
//$newMail->to[] = array("baxxdd#126.com" , "tobailing" );
$newMail->to[] = array("baxxdd#126.com" , "126 bailing" );
$newMail->Subject = "3-9-bailing Test mail";
$newMail->Body = " from mail functions";
$newMail->AltBody = "hl alt";
$newMail->WordWrap = 0;
$newMail->Helo = "eqhi.com";
$newMail->PluginDir = $INCLUDE_DIR;

$newMail->Sendmail = '/usr/sbin/sendmail'
$newMail->IsMail();

if(!$newMail->Send()){
    
echo $newMail->ErrorInfo;
}
echo $newMail->ErrorInfo;

?>


 

Posted on 2006-03-10 09:15  古代  阅读(547)  评论(0编辑  收藏  举报