<?
function send_multimail($message, $recipient_email = Array(), $replace = Array())
{
foreach($replace as $str){
$txt[] = vsprintf($message, $str);
}
//print_r($txt); //debug
$subject = "=?utf-8?B?".base64_encode("ชื่อเรืองภาษาไทยก็ได้")."?=";
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/plain; charset=utf-8\r\n";
$header .= "From:
[email protected]\r\n";
$header .= "Reply-To:
[email protected]\r\n";
$i=0;
foreach($recipient_email as $to){
mail($to, $subject, $txt[$i], $header);
$i++;
}
}
// Send multi email
$message ="test send mail to %s";
send_multimail($message, Array('
[email protected]','
[email protected]','
[email protected]','
[email protected]'),Array('
[email protected]','
[email protected]','
[email protected]','
[email protected]'));
?>
ส่งได้หลายอีเมล์ แต่ข้อความเดียวกัน จะวนลูปส่งจนครับตามอาเรย์ แต่ถ้าอยากให้หลายข้อความแตกต่างกันก็ดัดแปลงเอาไม่ยากครับ
