Jump to content

PHP: Query for Sending Email


benchew0904

Recommended Posts

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            [email protected]    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 = "[email protected]";

$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

Link to comment
https://forums.phpfreaks.com/topic/251682-php-query-for-sending-email/
Share on other sites

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?

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.