我想向多个用户发送电子邮件,我有4封电子邮件,每封4封电子邮件与其他用户不同。我只是希望我可以发送一封电子邮件给所有人,而不需要BCC和CC的东西,所以电子邮件将作为ONE BY ONE发送给他们。 这是我的代码:
$_SESSION['eventAdminEmail'] = array('mohsin@test.com, mohsin@test.com, mohsin@test.com, mohsin@test.com');
$toAdmin = $_SESSION['eventAdminEmail'];
$adminSubject = "hello";
$Mail_headers = "MIME-Version: 1.0".PHP_EOL;
$Mail_headers .= "Content-type: text/html; charset=iso-8859-1".PHP_EOL;
$Mail_headers .= "From: test Support <test@test.org>".PHP_EOL;
if(isset($_SESSION['eventAdminEmail'])){
mail(explode(', ', $toAdmin), $adminSubject, $adminMessage, $Mail_headers);
}
答案 0 :(得分:0)
你可以使用循环
$_SESSION['eventAdminEmail'] = array('mohsin@test.com, mohsin@test.com, mohsin@test.com, mohsin@test.com');
$adminSubject = "hello";
$Mail_headers = "MIME-Version: 1.0".PHP_EOL;
$Mail_headers .= "Content-type: text/html; charset=iso-8859-1".PHP_EOL;
$Mail_headers .= "From: test Support <test@test.org>".PHP_EOL;
if(isset($_SESSION['eventAdminEmail']))
{
$toAdmin = $_SESSION['eventAdminEmail'];
$arr_emails = explode(', ', $toAdmin[0]);
foreach($arr_emails as $email)
{
mail($email, $adminSubject, $adminMessage, $Mail_headers);
}
}
答案 1 :(得分:0)
它应该是工作
$eventAdminEmail = $_SESSION['eventAdminEmail'];
$arr_eventAdminEmail = array();
$arr_eventAdminEmail = explode(",", $eventAdminEmail[0]);
foreach($arr_eventAdminEmail as $key=>$email_id)
{
mail($email_id,$adminSubject, $adminMessage, $Mail_headers);
}
答案 2 :(得分:-3)
你可以这样使用
$toAddres=explode(', ', $_SESSION['eventAdminEmail'][0]);
if(isset($_SESSION['eventAdminEmail'])){
foreach($toAddres as $toMail){
mail($toMail, $adminSubject, $adminMessage, $Mail_headers);
}
}