I normally mail single user on php but what I dont know if its possible to fetch all emails from the users table and bundle it in one variable ($to
) and then mail it together with
mail($to, $subject, $message, $headers);
Can anyone help me with the syntax on how to mail multiple users? I am new to php and mysqli. Thanks.
PHP send mail to multiple email addresses
$recipients = array(
"youremailaddress@yourdomain.com",
// more emails
);
$email_to = implode(',', $recipients); // your email address
$email_subject = "Contact Form Message"; // email subject line
$thankyou = "thankyou.htm"; // thank you page
mail($email_to, $email_subject, $thankyou);
Note that you can use a custom message in place of $thankyou
if you just want a standard message instead of html.