0

我有一组电子邮件,想为数组中的每个条目发送一封电子邮件,但目前它只将其发送到第一个地址。我环顾四周,看不出我做错了什么。

//This is the array
$emails = array($teamleademail, $coleademail, $sponsoremail, $facilitatoremail, $cisupportemail);

//Now the foreach statment    
foreach ($emails as $value) {
    //pulls in email sending code
    require_once ("Mail.php");
    //variables required to send the email 
     $from = "Scope Sheet Process Database (no reply)<scopesheetprocess@goodrich.com>";
     //Make the $to variable that of the email in the array
     $to = "$value";
     $subject = "Scope Sheet $scopesheetid Closed";
     $body = "Scope Sheet $scopesheetid has been closed and can no longer be edited.";
     //send email code
     require_once ("sendemail.php");
}  

由于 IT 问题,我正在使用 pear php 发送电子邮件,但这无关紧要,因为它应该每次都运行脚本并发送单独的电子邮件。

4

1 回答 1

2

问题是这一行:

require_once ("sendemail.php");

...应该只是

require ("sendemail.php");

事实上,它只会包含在循环的第一次迭代中,因此只会发送第一封电子邮件。

这本身可能无法解决您的问题 - 如果没有,我们需要查看sendemail.php.

于 2012-07-13T10:26:06.813 回答