dpecb06062 2010-07-16 21:00
浏览 104

从MySql Recordset向多个收件人发送电子邮件

I want to send an email to multiple recipients using PHP mail() function. The email message is simply a reminder that a membership is due to expire so email addresses will come from MySql database query. There would anywhere from 2-10 at any given time. I found the following code but it generate errors. The problem is not with my query as it generates an accurate recordset. This is the code I have: Hopefully someone can help. By the way, I am very much a novice so need easy straight forward explanation. Thanks in advance:

<?php 

$recipients = ("SELECT email FROM tblMembers WHERE search criteria=criteria"); 
$email_list = $db->query($recipients); 
foreach($email_list as $row) { 
$to = $row['email']; 
$subject = "Membership Renewal";
$headers = "From: Membership Coordinator <membership@myaddress.net>
";
$message = "THIS IS AN AUTOMATED EMAIL.  PLEASE DO NOT REPLY""
""etc, etc, etc";
  if ( mail($to,$subject,$headers,$message) ) {
   echo "Email was sent successfully";
   } else {
   echo "Email delivery has failed!";
   }
} 
?> 
  • 写回答

2条回答 默认 最新

  • dqyq88053 2010-07-16 22:12
    关注

    As far as I know, then $headers comes after $message, so you should just change the order in mail() and be more aware in future.

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line