I have problem receiving notification using bunch of email recipients, the only email received notification is the last email on the line (email5@mysite.com) im been wondering why and what's the problem? Any help will be appreaciated.
<?php
class QIF_Email {
function send_email(){
$to= "email1@mysite.com,email2@mysite.com,email3@mysite.com,email4@mysite.com,email5@mysite.com,";
$subject="Inquiry";
$header="mysite.com - Inquiry";
$message="Date: ".$_POST['date']." \r\n";
$message.="Name: ".$_POST['name']." \r\n";
$message.="Company Name: ".$_POST['company_name']." \r\n";
$message.="Contact: ".$_POST['contact']." \r\n";
$message.="Address: ".$_POST['address']." \r\n";
$message.="City: ".$_POST['city']." \r\n";
$message.="State: ".$_POST['state']." \r\n";
$message.="Zip Code: ".$_POST['zip_code']." \r\n";
$message.="Telephone / Fax: ".$_POST['telephone']." \r\n";
$message.="Email Address: ".$_POST['email_address']." \r\n";
$message.="Comments: ".$_POST['comments']." \r\n";
$sentmail = mail($to,$subject,$message,$header);
}
}
$qif = new QIF_Email;
$qif->send_email();
?>
Store your recipients as an array and send the email to each one
class QIF_Email {
function send_email($to){
$subject="Inquiry";
$header="mysite.com - Inquiry";
$message="Date: ".$_POST['date']." \r\n";
$message.="Name: ".$_POST['name']." \r\n";
$message.="Company Name: ".$_POST['company_name']." \r\n";
$message.="Contact: ".$_POST['contact']." \r\n";
$message.="Address: ".$_POST['address']." \r\n";
$message.="City: ".$_POST['city']." \r\n";
$message.="State: ".$_POST['state']." \r\n";
$message.="Zip Code: ".$_POST['zip_code']." \r\n";
$message.="Telephone / Fax: ".$_POST['telephone']." \r\n";
$message.="Email Address: ".$_POST['email_address']." \r\n";
$message.="Comments: ".$_POST['comments']." \r\n";
$sentmail = mail($to,$subject,$message,$header);
}
}
$to[] = "email1@mysite.com";
$to[] = "email2@mysite.com";
for($i = 0; $i < count($to); $i++){
$qif = new QIF_Email;
$qif->send_email($to[$i]);
}
Not best practice but it should do the job
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.