I want to send newsletter to my subscribers. The email adress of my subscribers are inserted into MYSQL database.
This below coding i am using to send.
<?php if(isset($_POST['send'])){
$servername = "localhost";
$username = "#";
$password = "#";
$dbname = "db_table";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT ALL email FROM db_table";
$result = $conn->query($sql);
if ($result->num_rows > 0) {while($row = $result->fetch_assoc()){
$emails = $row["email"];
}
} else {
}
$conn->close();
$email_to = "$emails";
$headers = "From:" . "noreply@website.in";
$subject = "Newsletter";
$message = 'Hello There,
This is and Test email.
Thank you';
mail($email_to,$subject,$message,$headers);
}
?>
But this is not working. Any help?