index.php file
<form action="emailsendtoall.php" method="post" enctype="multipart/form-data">
<?php
include 'db.php';
$sql = mysql_query("select * from tablename"); // here we are show all email form table , on which we want to send emails
while($result = mysql_fetch_array($sql))
{
?>
<?php echo $result['email']; ?> ,
<?php
}
?>
<input type = "submit" class = "btn btn-primary btn-sm" value = "Send" >
</form>
send-email.php file
<?php
require 'db.php'; // database connection file
$sql = mysql_query("select * from tablename"); // select All Email From Table Name
while($result = mysql_fetch_array($sql))
{
$email = $result['email'];
if($email)
{
$get =mysql_query("select * from member where email = '$email'");
$getr = mysql_fetch_array($get);
$emailuser = $getr['email']; // user email
$password = $getr['password']; // user password or // you can fetch multiple detail which you want to send
$subject = 'Multiple Email With Their Multiple Details';
$message = "<html><head></head>
<body>
<p>Welcome Message Your Email is ".$emailuser."<br>
And password is ".$password."<br>
(This is an auto-generated email. Please do not reply. Any further queries will be addressed at aoqr2019@gmail.com)
</body></html>";
mail($emailuser, $subject, $message);
?>
<script>
alert("Registration Details Send to All Member");
window.location='index.php';
</script>
<?php
}
else
{
?>
<script>
alert("None Email Remain to send");
window.location='index.php';
</script>
<?php
}
}
?>