简体   繁体   English

发送多个电子邮件PHP

[英]Sending Multiple E-Mail PHP

Well guys, I'm trying to send multiple emails with different contents. 伙计们,我正在尝试发送多个具有不同内容的电子邮件。 but it doesn't work properly and I think I already stuck on this @_@. 但是它不能正常工作,我想我已经停留在这个@ _ @上了。 can you please help me find the problem? 你能帮我找到问题吗?

well thx, sorry for the bad English. 谢谢,不好意思的英语。

$email = array('blazriku@gmail.com','henrikus.antony@gmail.com');
$subject = array("send message", "Welcome");
$message = array($_POST['Message'],);
$messages = implode(',',$message);
$name = array('Admin','Admin');
$to=$email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: kebunbibit.id <noreply@yourwebsite.com>'."\r\n" . 'Reply-To: '.$name.' <'.$email.'>'."\r\n";
$headers .= 'Cc: admin@yourdomain.com' . "\r\n"; //untuk cc lebih dari satu   tinggal kasih koma
for($i = 0; $i < count($message); $i++;){
    @mail($to, $subject[$i], $messages[$i], $headers);
}    
if(@mail)
{
print "<script>window.alert('E-Mail Terkirim!')</script>";  
print "<script>window.location='home.php?page=surat_jalan'</script>";    
}
else{
print "<script>window.alert('E-Mail Gagal Terkirim!')</script>";  
print "<script>window.location='home.php?page=surat_jalan'</script>";      
}

In the for-loop you have to get length from messages not the single message. 在for循环中,您必须从消息而不是单个消息中获取长度。

for($i = 0; $i < count($messages); $i++;){
    @mail($to, $subject[$i], $messages[$i], $headers);
}    

Maybe the 's' in the for-loop should fix your problem. 也许for循环中的“ s”应该可以解决您的问题。 Otherwise the failure maybe comes up later. 否则,故障可能稍后出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM