Auto response mail in php

Here is an example of how to send an auto-response email in PHP:

Step 1: Create a PHP script

Create a new PHP file (e.g. autoresponse.php) and add the following code:

<?php

// Set the email address and subject of the auto-response email
$email_to = '[email protected]';
$subject = 'Auto-response from our team';

// Set the message body of the auto-response email
$message = 'Thank you for contacting us! We will get back to you soon.';

// Set the sender's email address
$from_email = '[email protected]';

// Set the email headers
$headers = 'From: '. $from_email. "\r\n".
           'Reply-To: '. $from_email. "\r\n".
           'MIME-Version: 1.0'. "\r\n".
           'Content-Type: text/plain; charset=UTF-8';

// Set the email body
$body = $message;

// Send the email using the mail() function
mail($email_to, $subject, $body, $headers);

?>

Step 2: Configure the script to run automatically

To make the script run automatically when a new email is received, you'll need to configure your email server or hosting provider to run the script as a cron job or scheduled task. Here are the general steps:

Step 3: Test the auto-response email

To test the auto-response email, send an email to the email address specified in the script ($email_to). The script should send an auto-response email back to the sender with the subject and message specified in the script.

Note: Make sure to replace the placeholders ($email_to, $subject, $message, and $from_email) with your actual email address and settings. Also, be aware that this is a basic example and you may want to add more functionality to your auto-response email, such as storing the email in a database or sending a confirmation email to the recipient.