benchew0904 Posted November 23, 2011 Share Posted November 23, 2011 Hi I need some help. I want to send an email to user to inform them about their next appointment date but I don't know how to do the query. My database look something like this: id | name | email | contact_no | appointment_date 1 Jon jon@abc.com 12345678 24/12/2011 The appointment date is added in by user so it will keep updating to the latest date. <?php include 'config.php'; $sql = executeSelectQuery($MYSQL); if($sql){ $to = $_POST ['email']; $subject = "Appointment Date"; $message = "Hello! Please be informed that your next appointment is on $appointment_date"; $from = "123@abc.com"; $headers = "From: $from"; $sent = mail($to,$subject,$message,$headers); if ($sent){ $statusMessage = "Mail Successfully Sent."; }else{ $statusMessage = "Mail Unsuccessfully Sent"; } ?> Please kindly help. Thanks Ben Quote Link to comment https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/ Share on other sites More sharing options...
Pikachu2000 Posted November 23, 2011 Share Posted November 23, 2011 When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/#findComment-1290731 Share on other sites More sharing options...
voip03 Posted November 23, 2011 Share Posted November 23, 2011 add this headers $headers = "MIME-Version: 1.0\r\n"; $headers.= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers.= "From: $from\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/#findComment-1290735 Share on other sites More sharing options...
Pikachu2000 Posted November 23, 2011 Share Posted November 23, 2011 add this headers $headers = "MIME-Version: 1.0\r\n"; $headers.= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers.= "From: $from\r\n"; You didn't even read the question, did you? Quote Link to comment https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/#findComment-1290736 Share on other sites More sharing options...
voip03 Posted November 23, 2011 Share Posted November 23, 2011 add this headers $headers = "MIME-Version: 1.0\r\n"; $headers.= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers.= "From: $from\r\n"; You didn't even read the question, did you? Yes Quote Link to comment https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/#findComment-1290755 Share on other sites More sharing options...
voip03 Posted November 23, 2011 Share Posted November 23, 2011 $message = "Hello! Please be informed that your next appointment is on $appointment_date"; In the message variable you can insert table and inline CSS for styling the table OR CSS layout Quote Link to comment https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/#findComment-1290756 Share on other sites More sharing options...
PFMaBiSmAd Posted November 23, 2011 Share Posted November 23, 2011 benchew0904, whomever assigned this, probably wanted you to send the reminder email once, a specific number of days ahead of when the appointment is scheduled? Also, your appointment_date column needs to be a mysql DATE data type so that you can perform the date check in the query. The 24/12/2011 format cannot be directly used by mysql. Edit: Also, if for some reason your code doesn't send out a reminder at the intended time (your code didn't run for some reason, email could not be sent for some reason, ...), what do you want to do? Keep trying and for how long? Quote Link to comment https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/#findComment-1290761 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.