Making an autoresponder in php

948 views Asked by At

I have a website that has a contact form. And when someone uses it I receive the message. But I would like to set up an autoresponder to inform the person who contacted me that their message has been received etc.

Code:

<?php
    $data = json_decode(file_get_contents('admin/data/contact.txt'));
    include('includes/header.php');
    if(isset($_REQUEST['name'])) {
        $to = $settings->email;
        $subject = 'Contact from Website';
        $headers = "From: " . strip_tags($_REQUEST['email']) . "\r\n";
        $headers .= "Reply-To: ". strip_tags($_REQUEST['email']) . "\r\n";
        //$headers .= "CC: [email protected]\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        $message = "Hi, A message from contact form.";
        $message .= "<br /><br /><br />Name: ".$_REQUEST['name'];
        $message .= "<br />Email: ".$_REQUEST['email'];
        $message .= "<br />Subject: ".$_REQUEST['subject'];
        $message .= "<br />Message: ".$_REQUEST['message'];
        mail($to, $subject, $message, $headers);
        $msg = 'Your Message has been sent. Thank You.';
    }
    $btn = '<input type="submit" style="font-size: 14px; font-style: normal; height: auto; color: #fff; border-radius: 15px; border: none;" class="btn_new" value="SEND" />';
?>

How can I edit this code in order to set this up?

Thank you

1

There are 1 answers

5
rescobar On BEST ANSWER
....
....
$message .= "<br />Message: ".$_REQUEST['message'];
if(@mail($to, $subject, $message, $headers))
{
  echo "Mail Sent Successfully";      
  //Send autoresponder email to $_REQUEST['email'];
  //inform the person who contacted me that their message has been received etc.

}
  else
{
  echo "Mail Not Sent";
}