I am trying to make a php page where once an item in the database is updated it sends an email to any user linked to that item. The code I have retrieves the email addresses and places them in array. The issue is that the emails are not being sent, where am I going wrong?
<?php
require_once 'config/init.php';
$id = $_GET['id'];
$mysqli_conn = new mysqli($db['hostname'],$db['username'],$db['password'], $db['database']);
if ($mysqli_conn -> connect_errno) {//check the connection
print "Failed to connect to MySQL: (" . $mysqli_conn -> connect_errno . ") " . $mysqli_conn -> connect_error;
}
$result = $mysqli_conn->query("SELECT * From Logins")
$headers.= "\r\n";
$headers.= "Content-type: text/html\r\n";
$to = '';
$headers.="Bcc: ";
while ($row = $result->fetch_array()) {
$headers.=$row['Email'].", ";
//$to.=$row['Email'].", ";
}
$subject = "Subject";
$headers.="\r\n";
$mailbody = "Body of email";
$mailResult = @mail($to, $subject, $mailbody, $headers);
print $to;
print $subject;
print $mailbody;
print $headers;
?>