Send mail to all subscribe users from mysql

Hi,
In my website, i have a blog section and a subscribe section. Once a user is subscribed to my posts then email will be stored in the database.

And once the Admin posts an article then system will retrieve all the email ids from DB and will send mail to each user in loop system.

Issue: The mail is been sent only to the first user in the DB.

I have used the below query–

$result=mysql_query(“select email from XYZ where status = 1”) //1 means subscribed user
while($row = mysql_fetch_array($result)) {
$mail_to = $row[‘emailid’];
//subject
//content
mail($mailto, $from, $subject, $content )

You assign the email to a variable called $mail_to

[php]$mail_to = $row[‘emailid’]; [/php]

But you pass in a variable called $mailto into the mail function without the underscore. So that’s not going to work.

[php]mail($mailto, $from, $subject, $content )[/php]

Then in your query… you select a column named email

[php]$result=mysql_query(“select email from XYZ where status = 1”) //1 means subscribed user[/php]

and you assign a column named emailid

[php] $mail_to = $row[‘emailid’];
[/php]

That’s not going to work either…

Sponsor our Newsletter | Privacy Policy | Terms of Service