Simple PHP Auto Responder Script

Dee Gonzalez picture Dee Gonzalez · Sep 19, 2012 · Viewed 16.6k times · Source

I built a simple php script for clients to email me and it works great. But I would like to add an auto-response to the script saying:

Thank you for your interest. We will get back to you as soon as possible.

Sincerely,
(My Name)

Here is the script I am already using:

// ******* PROCESS EMAILS
$emailSubject = '*** Business Lead - '.$_POST['full_name'].' ***';
$webMaster = '[email protected]';
//Gather Info
$leadname = $_POST['full_name'];
$leademail = $_POST['email'];
$leadphone = $_POST['phone'];
$leadip = $_SERVER['REMOTE_ADDR'];


$body = <<<EOD
<br><hr><br>
<b>***** $emailSubject ***</b><br>
<br><hr><br>

<b>Name:</b><br>
$leadname <br><br>

<b>Email:</b><br>
$leademail <br><br>

<b>Phone:</b><br>
$leadphone <br><br>

<b>IP Address:</b><br>
$leadip <br><br>

EOD;

$headers = "From: $leademail\r\n";
$headers .= "Content-type:  text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
// ******* PROCESS EMAILS

Is there anything that I can add to this already to add in the text that's not too mcuh code? Thank you in advance. :)

Answer

jtheman picture jtheman · Sep 19, 2012

That would be:

$message = "Thank you for your interest. We will get back to you as soon as possible.<br />Sincerely,<br />(My Name)";
$subject = "Confirmation";

$headers2 = "From: $webMaster\r\n";
$headers2 .= "Content-type:  text/html\r\n";
mail($leademail, $subject, $message, $headers2);