Page 1 of 1

PHP Mail script not working in DB Query

Posted: Wed Apr 06, 2016 3:30 am
by simonmlewis
Apart from the lacking PDO, is there any obvious reason why this won't send an email out?
Our registration script works and sends email, but this won't. And it's the same script.

Code: Select all

$result = mysql_query ("SELECT * FROM admin WHERE id='$id'");
      while ($row = mysql_fetch_object($result))
        {
$to = "$row->email";
        $subject =  "Account Active";
        $headers = "From: info@domain.co.uk";
        $body = "Dear $firstname

We are pleased to announce that your account is now active.

Welcome.
To login, simple go to the website, and click the Login link at the top.


Kind regards       
";
        mail ($to, $subject, $body, $headers);
    }    

Re: PHP Mail script not working in DB Query

Posted: Wed Apr 06, 2016 6:21 am
by Celauran
Same environment? Is it not being sent or not being received? Anything in the mail server logs? Have you checked that $row->email contains values?

Re: PHP Mail script not working in DB Query

Posted: Wed Apr 06, 2016 11:13 pm
by Christopher
Yes, have you checked if mail() works at all -- with any email address. Check the logs as mentioned. How about the return value for mail()?