我正在尝试使用数据库模拟电子邮件行为。这些是我用于向一个收件人发送邮件的代码。如何将其发送给多个收件人。
if($to=="" || $sub=="" || $msg=="")
{
$err= "<h3 style='color:red'>fill the related data first</h3>";
}
else
{
$d=mysqli_query($con,"SELECT * FROM userinfo where email='$to'");
$row=mysqli_num_rows($d);
if($row==1)
{
mysqli_query($con,"INSERT INTO usermail values('','$to','$id','$sub','$msg','$file',sysdate())");
$err= "<h3 style='color:blue'>Message sent...</h3>";
}
else
{
$sub=$sub."--"."msg failed";
mysqli_query($con,"INSERT INTO usermail values('','$id','$id','$sub','$msg','$file',sysdate())");
$err= "<h3 style='color:red'>Message failed because reciever not found...</h3>";
}
}
答案 0 :(得分:1)
如果我遇到了你的问题:
让我们说$to="abc@x.com;zdf@x.com";
else
{
$toStack = explode(';',$to);
foreach($toStack as $to){
$d=mysqli_query($con,"SELECT * FROM userinfo where email='$to'");
/** and the rest of your code from the else block **/
}
}
度过美好的一天..