Jump to content

Send Email alert to user


dapcigar
Go to solution Solved by trq,

Recommended Posts

Am trying to get an email address from the DB and send an alert but it's not working.. :facepalm:

 

$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);

Link to comment
Share on other sites

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);
?>
Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.