0
How can I send an email to each of the users registered in the database?
This way I can only send to a user, in this case an email is sent to the last user of the comic.
<?php
header("Content-Type: text/html; charset=UTF-8");
$sql = "SELECT * FROM `user`";
$query = $mysqli->query( $sql );
if( $query->num_rows > 0 ) {
while($row = $query->fetch_assoc()) {
$email[]=$row['email'];
$u=$row['username'];
}
$to = "$email";
$subject = "Assunto";
$txt = "texto exemplo";
$headers = "From: suporte@localhost" . "\r\n" .
"CC: suporte@localhost";
mail($to,$subject,$txt,$headers);
} else {
}
?>
How do you want to do? an email for each person or an email for everyone?
– rray
an email to each @rray person
– David Concha
Plays the
mail()
inside the while then.– rray
true @rray :)
– David Concha
Oops, just a few comments you should pay attention to. How many emails are there? Where is the application hosting will support sending? Aren’t there trigger limits per hour? If you don’t see these details you can simply block sending mail from the server. Among others, how to put the domain in black list and so on...
– MoisesGama