-1

Trying to send email from the contact list from the database and it does not send.

<?php
    include_once "../../mysqli_connect.php";
    $sql= mysqli_query($dbc, "SELECT * FROM Customer_Info");
    
    while($row= mysqli_fetch_array($sql)){
        
        $email = $row["email"]; 
        
        $mail_body = file_get_contents('../forms/promo_email_form.html');
            
            
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= "From: info@grillontherock\r\n";
            
            
        $to = "$email";
        $subject = "";
        
        $mail_result = mail($to, $subject, $mail_body, $headers);
        
?>

I have tried many different ways but I have no idea how to send multiple emails.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Danny Yoon
  • 27
  • 10

1 Answers1

-1

You implode an array of recipients:

$recipients = array('hassan@gmail.com', 'jill@gmail.com');

mail(implode(',', $to), $submit, $message, $headers); See the PHP: Mail function reference - http://php.net/manual/en/function.mail.php

Receiver, or receivers of the mail.

The formatting of this string must comply with » RFC 2822. Some examples are: