我有一系列电子邮件,想要为阵列中的每个条目发送电子邮件,但目前它只将其发送到第一个地址。我环顾四周,看不出我做错了什么。
//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发送电子邮件,但这应该没关系,因为它应该每次运行脚本并发送单独的电子邮件。
答案 0 :(得分:2)
问题在于这一行:
require_once ("sendemail.php");
......应该只是
require ("sendemail.php");
实际上,它只会被包含在循环的第一次迭代中,因此只会发送第一封电子邮件。
这本身可能无法解决您的问题 - 如果不是,我们需要查看sendemail.php
中的代码。