用phpmailer如何群发邮件 数据库邮件库email 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 简单说一下2个方法,可试试看有问题再讨论1. 你上一个帖子提到的用2页处理从 A.php 获取10条email资料 (select email from bl_email where ..... )然後sumit表单POST到B.php处理寄送动作2. 用ajax不换页处理从 A.php 获取10条email资料 (select email from bl_email where ..... )按下按钮後用ajax post 10条email到後端 B.php处理寄送动作 回复1楼为何只读取到一条记录<?php $conn=mysql_connect("localhost","root","");//连接数据库 mysql_select_db("email",$conn);//连接哪个库 mysql_query("set names utf-8");//编码方式 $sql="select * from bl_email";//查询那个表 $result=mysql_query($sql,$conn); while($array=mysql_fetch_array($result)){ $email=$array["address"]; }; print_r("$email"); ?> 用这句看看印出什麽结果print_r(mysql_fetch_array($result)); 难道错误在这句吗打印的结果Array ( [0] => 2 [id] => 2 [1] => tom [name] => tom [2] => [email protected] [address] => [email protected] [3] => 2345 [tel] => 2345 ) 回复3楼前面没看,4楼的打印是没加while的加了while的打印出 mysql_fetch_array(Resource id #4) 回复3楼问题找到了,打印没有放在while里面 我直接把上面取得变量$email加到了这个上面$mail->AddAddress("$email","h"); //添加收件人这样可以提交,就是邮件发不过去 $mail->AddAddress("$email","h"); 改为foreach($email as $em){ $mail->AddAddress("$em","h"); } if(!$mail->Send()) { echo "发送失败: " . $mail->ErrorInfo; } 回复11楼和12楼提示:You must provide at least one recipient email address. 为什么没有获得地址程序 $conn=mysql_connect("localhost","root","");//连接数据库 mysql_select_db("email",$conn);//连接哪个库 mysql_query("set names utf-8");//编码方式 $sql="select * from bl_email";//查询那个表 $result=mysql_query($sql,$conn); while($array=mysql_fetch_array($result)) { $email=$array["address"]; }if(is_array($email)) { foreach($email as $em) { $mail->AddAddress("$em","h"); } } if(!$mail->Send()){ echo "发送失败: " . $mail->ErrorInfo; ?><script type="text/javascript">alert('无法发送邮件,错误信息:'.$mail->ErrorInfo);window.location = 'send.php';</script><?php } else { //echo "邮件已经发送";?><script type="text/javascript">alert('邮件发送成功');window.location = 'send.php';</script><?php }?> if(is_array($email))如果$email不是array的情況,你沒有寫。 问题已经解决在while上面给$email定义一个空的数组就解决了前面应该问题是在打印在while里面可以出来多个值在外部打印就只出来一个值然后下面的$mail->AddAddress("$em","h");在按照版主的加个foreach循环就可以群发了 请教下楼主,你所说的 在while上面给$email定义一个空的数组是下面这样吗?我也是新手 while($array=mysql_fetch_array($result)) { $email[]=$array["address"]; } 回复16楼我是这样做的$email=array();while($row=mysql_fetch_array($result)){ $email[]=$row["address"]; } while之前的数组应该不用定义吧?$email[]会自动创建一个数组。 折腾1天,js调用php不成功,求助!!! 用命令行执行的PHP文件能不能写文字到外部文本文件 高手为我解答谷歌地图难题,,可恶的客户 php序列化 PHP 的move_uploaded_file问题 一个php连接SQL2000的问题? 跟老板谈了10月离职,散分100 明天继续加分 求论坛镜像方案~!!!!!! 有没有简单的比较好的php用AJAX引擎和教程 php取数字 关于PHP写Cookies的特殊字符问题。 $array[0]与$array['0']的区别
从 A.php 获取10条email资料 (select email from bl_email where ..... )
然後sumit表单POST到B.php处理寄送动作2. 用ajax不换页处理
从 A.php 获取10条email资料 (select email from bl_email where ..... )
按下按钮後用ajax post 10条email到後端 B.php处理寄送动作
为何只读取到一条记录
<?php
$conn=mysql_connect("localhost","root","");//连接数据库
mysql_select_db("email",$conn);//连接哪个库
mysql_query("set names utf-8");//编码方式
$sql="select * from bl_email";//查询那个表
$result=mysql_query($sql,$conn);
while($array=mysql_fetch_array($result)){
$email=$array["address"];
};
print_r("$email");
?>
用这句看看印出什麽结果
print_r(mysql_fetch_array($result));
打印的结果
Array ( [0] => 2 [id] => 2 [1] => tom [name] => tom [2] => [email protected] [address] => [email protected] [3] => 2345 [tel] => 2345 )
前面没看,4楼的打印是没加while的
加了while的
打印出 mysql_fetch_array(Resource id #4)
问题找到了,打印没有放在while里面
$mail->AddAddress("$email","h"); //添加收件人
这样可以提交,就是邮件发不过去
$mail->AddAddress("$email","h");
改为
foreach($email as $em){
$mail->AddAddress("$em","h");
}
if(!$mail->Send()) {
echo "发送失败: " . $mail->ErrorInfo;
}
提示:You must provide at least one recipient email address.
为什么没有获得地址
程序
$conn=mysql_connect("localhost","root","");//连接数据库
mysql_select_db("email",$conn);//连接哪个库
mysql_query("set names utf-8");//编码方式
$sql="select * from bl_email";//查询那个表
$result=mysql_query($sql,$conn);
while($array=mysql_fetch_array($result))
{
$email=$array["address"];
}if(is_array($email))
{
foreach($email as $em)
{
$mail->AddAddress("$em","h");
}
} if(!$mail->Send()){
echo "发送失败: " . $mail->ErrorInfo;
?>
<script type="text/javascript">
alert('无法发送邮件,错误信息:'.$mail->ErrorInfo);
window.location = 'send.php';
</script>
<?php
} else {
//echo "邮件已经发送";
?>
<script type="text/javascript">
alert('邮件发送成功');
window.location = 'send.php';
</script>
<?php
}
?>
在while上面给$email定义一个空的数组
就解决了
前面应该问题是在
打印在while里面可以出来多个值
在外部打印就只出来一个值
然后下面的$mail->AddAddress("$em","h");在按照版主的加个foreach循环
就可以群发了
我也是新手 while($array=mysql_fetch_array($result))
{
$email[]=$array["address"];
}
我是这样做的
$email=array();
while($row=mysql_fetch_array($result))
{
$email[]=$row["address"];
}