0

基本上我需要通知某些用户应用程序中发生的事情。我从数据库中获取用户,一切正常,但是当我发送电子邮件时,只有列表中的第一个收到它,我尝试切换他们带来的顺序,但仍然与特定的邮件客户端无关。

我尝试一个一个发送,现在一起发送,似乎都不起作用。

以前有过这种情况吗?我正在使用一些带有 linux 的亚马逊服务器,但它是客户端的客户端服务器,所以我不能真正把头放在整个配置上。

$ul = $this->q2ar("SELECT * FROM usr WHERE role_id in(1,7)");
//get admins from db
$ntf = '';
foreach($ul as $usr){
    $headers  = 'MIME-Version: 1.0 '." \r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . " \r\n";
    $headers .= 'From: Centinelas <centinelas@serviciochevrolet.com.ec>' . "  \r\n";
    $body = "mail content";
    $ntf .= "'".$usr['email']."'".', ';
}
$ntf = substr_replace($ntf ,"",-2);
$ml = mail($ntf,'Nuevo Caso en Centinelas Chevrolet',$body,$headers,'- fcentinelas@serviciochevrolet.com.ec');
return('email where sent to :<br/>'.$ntf);
4

2 回答 2

0

尝试将电子邮件发送给一个人,例如您自己或发件人,然后使用抄送发送给其他人。

$ul = $this->q2ar("SELECT * FROM usr WHERE role_id in(1,7)");
foreach($ul as $usr){
    $ntf[] = $usr['email'];
}

$headers  = 'MIME-Version: 1.0 '." \r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . " \r\n";
$headers .= 'From: Centinelas <centinelas@serviciochevrolet.com.ec>' . "  \r\n";
$headers .= 'Cc: '.join($nft,",") . "  \r\n";
$body = "mail content";

$ml = mail('centinelas@serviciochevrolet.com.ec','Nuevo Caso en Centinelas Chevrolet',$body,$headers,'- fcentinelas@serviciochevrolet.com.ec');
return('email where sent to :<br/>'.join($nft,","));
于 2012-10-27T19:34:04.077 回答
0

整个使用 Cc: 字符串。

foreach($ul as $usr){
    $ntf .= (($ntf=="")?"":", ")."'".$usr['email']."'";
}

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Centinelas <centinelas@serviciochevrolet.com.ec>' . "\r\n";
$headers .= 'From: Centinelas <centinelas@serviciochevrolet.com.ec>' . "\r\n";
$headers .= 'Cc: '.$ntf.'' . "\r\n";

you have to add $ntf "CC:" to the HEADERS (for clarity it is often ok to send the mail to the sender)

于 2012-10-27T19:52:22.690 回答