上楼,感谢您的回答:1、select sdate,edate,email,name from testmail 这是有四条记录的,这个我肯定确定没问题.2、这是我输出的记录,只输出两条。 从以下来看,如果只取一条是没问题,但是如果有多条多个相同的日期phpmailer类就会报错。不知什么原因????当前时间 2008-07-21sdate :2008-07-21edate: 2008-07-19Message has been sent 当前时间 2008-07-21sdate :2008-07-19edate: 2008-07-21 Fatal error: Cannot redeclare class PHPMailer in C:\xampp\htdocs\test\phpmailer\class.phpmailer.php on line 35
$mail = new PHPMailer(); $address=$row[1]; //这个$row[1],上面跟时间比较,这里又是邮箱,错误$mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "mail.aaa.com.cn"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "Josh"; // SMTP username $mail->Password = "password"; // SMTP password $mail->From = "[email protected]"; $mail->FromName = "Mailer"; $mail->AddAddress("$address", "Josh Adams"); //所以这里得不到地址,发不出$mail->AddAddress("[email protected]"); // 这个地址虽然循环了4次,但只能发一次。邮件服务器当垃圾邮件服务器禁调了$mail->AddReplyTo("[email protected]", "Information"); $mail->WordWrap = 50; // set word wrap to 50 characters $mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML $name="$row[2]"; $mail->Subject ="$name 到期了"; $mail->Body = "This is the HTML message body <b>in bold! </b>"; $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; }
// } else { echo "不成功"; } } mysql_close(); ?>
关键是$address=$row[1]; 错了
非常感谢my_web, 我后来检查了一次改过来了,改正如下:在程序中我的两上是这样的:$address=$row[2];$name="$row[3]"; $mail->Subject ="$name 到期了"; 改完之后还是报以下错误,第一条发送邮件没问题,第二条就会报错,不知什么原因???? 如下:当前时间 2008-07-21 sdate :2008-07-21 edate: 2008-07-19 Message has been sent 当前时间 2008-07-21 sdate :2008-07-19 edate: 2008-07-21 Fatal error: Cannot redeclare class PHPMailer in C:\xampp\htdocs\test\phpmailer\class.phpmailer.php on line 35第一我想确认这个循环是不是有问题,为什么在第二个就报错?? 第二phpmailer难道不支持连续发邮件吗?有高手请教一下!!有人说用队列,不知哪位做过,能否参考一下??
我现在把四个参数都输出 来,请大家帮忙看看。为什么在第二个出错???多谢大家 sdate edate email name 2008-7-21 2008-7-19 [email protected] adfd 2008-7-15 2008-7-21 [email protected] bbcc 当前时间 2008-07-21 第一个2008-07-21 第二个2008-07-19 [email protected] adfd Message has been sent 当前时间 2008-07-21 第一个2008-07-19 第二个2008-07-21 [email protected] bbcc Fatal error: Cannot redeclare class PHPMailer in C:\xampp\htdocs\test\phpmailer\class.phpmailer.php on line 35 我现在运行的完整程序如下: <?php date_default_timezone_set('Asia/Shanghai'); $datesy=date("Y-m-d"); $format="<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>"; $db=mysql_connect('localhost','root',''); mysql_select_db('crm',$db);$sql="select date_signed_company1,date_signed_company2,emgmail,contract_number from contracts";mysql_query("set names gb2312"); $result=mysql_query($sql,$db); while ($row = mysql_fetch_array($result)) { echo"当前时间"; echo"<br>"; echo "$datesy"; echo"<br>"; //echo "$row[1]"; echo "</p>"; echo "第一个"; echo "$row[0]";echo "</p>"; echo "第二个"; echo "$row[1]"; echo "</p>"; echo "$row[2]"; echo "</p>"; echo "$row[3]"; echo "</p>";if($datesy==$row[0] || $datesy==$row[1]) {
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer(); $address=$row[2];$mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "smtp.sohu.com"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "sohu"; // SMTP username $mail->Password = "password"; // SMTP password$mail->From = "[email protected]"; $mail->FromName = "Mailer"; $mail->AddAddress("$address", "Josh Adams"); //$mail->AddAddress("[email protected]"); // name is optional $mail->AddReplyTo("[email protected]", "Information");$mail->WordWrap = 50; // set word wrap to 50 characters $mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML $name="$row[3]"; $mail->Subject ="$name 编号的合同到期了"; $mail->Body = "$name 编号的合同到期了!</b>"; $mail->AltBody = "This is the body in plain text for non-HTML mail clients";if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; }echo "Message has been sent"; echo "</p>"; }
用sohu的好像不稳定。 我今天也刚好做邮件 我下了个winmail 100个也没有问题 给你个demo 看2个以上能不能发 <?php require("class.phpmailer.php"); $mail = new PHPMailer(); //$address = $_POST['address']; $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "192.168.88.55"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "test"; // SMTP username $mail->Password = "test1"; // SMTP password$mail->From = "[email protected]"; $mail->FromName = "zhangjc"; $address[0] = "[email protected]"; $address[1] = "[email protected]"; for($i=0;$i<2;$i++) { $mail->AddAddress($address[$i]); } //$mail->AddAddress(""); // name is optional //$mail->AddReplyTo("", "");//$mail->WordWrap = 50; // set word wrap to 50 characters $mail->AddAttachment($att); // add attachments //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML$mail->Subject = "111"; $mail->Body = "222"; //$mail->AltBody = "This is the body in plain text for non-HTML mail clients";if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; }echo "Message has been sent"; ?>
select sdate,edate,email,name from testmail
放到MYSQL看看是不是显示出来四条数据,如果是的话,排除SQL语句的逻辑问题..
2:
$datesy==$row[0] ¦ ¦ datesy==$row[1]
你里面有判断,你在判断外面分别输出$datesy和$row[0]和$row[1]的值
看看他们什么时候相等..估计这两个其中一个逻辑发生了错误了..你的循环的写法没有错误.
这是有四条记录的,这个我肯定确定没问题.2、这是我输出的记录,只输出两条。 从以下来看,如果只取一条是没问题,但是如果有多条多个相同的日期phpmailer类就会报错。不知什么原因????当前时间
2008-07-21sdate :2008-07-21edate: 2008-07-19Message has been sent
当前时间
2008-07-21sdate :2008-07-19edate: 2008-07-21
Fatal error: Cannot redeclare class PHPMailer in C:\xampp\htdocs\test\phpmailer\class.phpmailer.php on line 35
程序发送邮件是很快的,可以认为是一瞬间的;如果服务器做了限制就会发不了(一般都会有所限制);
<?php
date_default_timezone_set('Asia/Shanghai');
$datesy=date("Y-m-d"); //当前系统时间 //$format=" <tr> <td>%s </td> <td>%s </td> <td>%s </td> <td>%s </td> <td>%s </td> <td>%s </td>"; $db=mysql_connect('localhost','root','');
mysql_select_db('test',$db);
$sql="select sdate,edate,email,name from testmail"; //sdate 与edate字段分别对应数据库中的两段时间
mysql_query("set names gb2312");
$result=mysql_query($sql,$db); while ($row = mysql_fetch_array($result))
{
printf ($format,$row[0],$row[1],$row[2],$row[3],$row[4],$row[5]);
if($datesy==$row[0] ¦ ¦ datesy==$row[1]) //目前是:如果定点刷新页面,程序只会去检测$row[1] 也就是edate时间,只会取一个而发送邮件,如果edate有2条或更多为2008--7-19的时间,都不会发邮件。我的目的是要:如果sdate ,date 哪怕是一百行数据,只要是与当前时间一致,都要发邮件。
{ require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$address=$row[1]; //这个$row[1],上面跟时间比较,这里又是邮箱,错误$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.aaa.com.cn"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "Josh"; // SMTP username
$mail->Password = "password"; // SMTP password $mail->From = "[email protected]";
$mail->FromName = "Mailer";
$mail->AddAddress("$address", "Josh Adams"); //所以这里得不到地址,发不出$mail->AddAddress("[email protected]"); // 这个地址虽然循环了4次,但只能发一次。邮件服务器当垃圾邮件服务器禁调了$mail->AddReplyTo("[email protected]", "Information"); $mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$name="$row[2]";
$mail->Subject ="$name 到期了";
$mail->Body = "This is the HTML message body <b>in bold! </b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
} echo "Message has been sent";
}
// } else
{
echo "不成功";
} }
mysql_close();
?>
错了
我后来检查了一次改过来了,改正如下:在程序中我的两上是这样的:$address=$row[2];$name="$row[3]";
$mail->Subject ="$name 到期了";
改完之后还是报以下错误,第一条发送邮件没问题,第二条就会报错,不知什么原因???? 如下:当前时间
2008-07-21 sdate :2008-07-21 edate: 2008-07-19 Message has been sent
当前时间
2008-07-21 sdate :2008-07-19 edate: 2008-07-21
Fatal error: Cannot redeclare class PHPMailer in C:\xampp\htdocs\test\phpmailer\class.phpmailer.php on line 35第一我想确认这个循环是不是有问题,为什么在第二个就报错??
第二phpmailer难道不支持连续发邮件吗?有高手请教一下!!有人说用队列,不知哪位做过,能否参考一下??
2008-7-21 2008-7-19 [email protected] adfd
2008-7-15 2008-7-21 [email protected] bbcc
当前时间
2008-07-21
第一个2008-07-21 第二个2008-07-19 [email protected] adfd Message has been sent 当前时间
2008-07-21
第一个2008-07-19 第二个2008-07-21 [email protected] bbcc
Fatal error: Cannot redeclare class PHPMailer in C:\xampp\htdocs\test\phpmailer\class.phpmailer.php on line 35 我现在运行的完整程序如下:
<?php
date_default_timezone_set('Asia/Shanghai');
$datesy=date("Y-m-d");
$format="<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>"; $db=mysql_connect('localhost','root','');
mysql_select_db('crm',$db);$sql="select date_signed_company1,date_signed_company2,emgmail,contract_number from contracts";mysql_query("set names gb2312");
$result=mysql_query($sql,$db);
while ($row = mysql_fetch_array($result))
{
echo"当前时间";
echo"<br>";
echo "$datesy";
echo"<br>";
//echo "$row[1]";
echo "</p>";
echo "第一个";
echo "$row[0]";echo "</p>";
echo "第二个";
echo "$row[1]";
echo "</p>";
echo "$row[2]";
echo "</p>";
echo "$row[3]";
echo "</p>";if($datesy==$row[0] || $datesy==$row[1])
{
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$address=$row[2];$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.sohu.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "sohu"; // SMTP username
$mail->Password = "password"; // SMTP password$mail->From = "[email protected]";
$mail->FromName = "Mailer";
$mail->AddAddress("$address", "Josh Adams");
//$mail->AddAddress("[email protected]"); // name is optional
$mail->AddReplyTo("[email protected]", "Information");$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$name="$row[3]";
$mail->Subject ="$name 编号的合同到期了";
$mail->Body = "$name 编号的合同到期了!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}echo "Message has been sent";
echo "</p>";
}
else
{
echo "不成功";
}}mysql_close();
?>
程序发送邮件是很快的,可以认为是一瞬间的;如果服务器做了限制就会发不了(一般都会有所限制); 我没说明白????
先排除邮件服务器设置原因,要不你在循环中设个加处SLEEP,就是每隔个10分钟发一个试试;如果没问题就是服务器
的原因了;
我今天也刚好做邮件
我下了个winmail
100个也没有问题
给你个demo
看2个以上能不能发
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
//$address = $_POST['address'];
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "192.168.88.55"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "test"; // SMTP username
$mail->Password = "test1"; // SMTP password$mail->From = "[email protected]";
$mail->FromName = "zhangjc";
$address[0] = "[email protected]";
$address[1] = "[email protected]";
for($i=0;$i<2;$i++)
{
$mail->AddAddress($address[$i]);
}
//$mail->AddAddress(""); // name is optional
//$mail->AddReplyTo("", "");//$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment($att); // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML$mail->Subject = "111";
$mail->Body = "222";
//$mail->AltBody = "This is the body in plain text for non-HTML mail clients";if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}echo "Message has been sent";
?>
先不要去数据。看能不能发2条以上
$mail->AddAddress("$address", "Josh Adams");我加了一个这个:只收到一条邮件,是不是就只能发一条啊??如果只能发一条,那有什么办法来解决这个问题啊??
Fatal error: Cannot redeclare class PHPMailer in
这个问题
帮忙解决一下吧