dapcigar Posted May 15, 2014 Share Posted May 15, 2014 Am trying to get an email address from the DB and send an alert but it's not working.. $search3 = mysql_query("SELECT email FROM users WHERE department = '$department' AND (position = '$position')") or die(mysql_error()); $acct1 = mysql_fetch_array($search3); $email = $acct1['email'];$to = $email;$subject = 'New Requisition Alert';$message = 'You have a new message';$headers = 'From: server@test.com' . "\r\n" . 'Reply-To: admin@test.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();mail($to, $subject, $message, $headers); Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted May 15, 2014 Share Posted May 15, 2014 It might help if you provide a little more information. What do you mean by "it's not working"? Are you getting errors? If so, what are they? What have you tried to debug the issue? For example, have you checked if the database query returned anything? Have you enabled errors? Note that you can add the following snippet to the top of your script to show all PHP errors and warnings: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> Quote Link to comment Share on other sites More sharing options...
dapcigar Posted May 15, 2014 Author Share Posted May 15, 2014 After trying to display all errors, i got this Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\hyprops\staff\staff\rec_proc.php on line 229 Quote Link to comment Share on other sites More sharing options...
Solution trq Posted May 15, 2014 Solution Share Posted May 15, 2014 Do you have a mail server installed and configured locally? mail doesn't just send itself. Quote Link to comment Share on other sites More sharing options...
dapcigar Posted May 16, 2014 Author Share Posted May 16, 2014 Yeah, had to use a mail server and it worked.. was thinking i could do that without the mail server but i was wrong.. thanks for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.