How to send to multiple email recipients using php -
i have problem receiving notification using bunch of email recipients, email received notification last email on line (email5@mysite.com) im been wondering why , what's problem? 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 recipients array , send email 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 should job
Comments
Post a Comment