Jump to content

auto reply help and other


ski6

Recommended Posts

Hi Guys, can some one please help me create an auto reply message to user who fills in my form. I also please need help with this aswell. When i recieved the inquiry in my inbox(outlook 2007) it shows that it was sent from some server thing. How do i make it that it will show the user's address that just filled in the form so that when i click reply it will reply to the user's email adress

<?php

/* Set e-mail recipient */

$myemail  = "[email protected]";

/* Check all form inputs using check_input function */

$yourname = check_input($_POST['yourname'], "Enter your Full name");

$subject  = check_input($_POST['subject'], "Write a subject");

$email    = check_input($_POST['email']);

$number  = check_input($_POST['number'], "Enter a contact number");

$region = check_input($_POST['region']);

$query = check_input($_POST['query'], "Write a query");

 

/* If e-mail is not valid show error message */

if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))

{

    show_error("E-mail address not valid");

}

 

 

 

/* Let's prepare the message for the e-mail */

$message = " Hello)

 

Your contact form has been submitted by:

 

Name: $yourname

Subject: $subject 

Email: $email   

Conact Number: $number 

Region: $region

Query: $query

 

 

End of message

";

 

/* Send the message using mail() function */

mail($myemail, $subject, $message);

 

/* Redirect visitor to the thank you page */

header('Location: thanks.htm');

exit();

 

/* Functions we used */

function check_input($data, $problem='')

{

    $data = trim($data);

    $data = stripslashes($data);

    $data = htmlspecialchars($data);

    if ($problem && strlen($data) == 0)

    {

        show_error($problem);

    }

    return $data;

}

 

function show_error($myError)

{

?>

    <html>

    <body>

 

    <b>Please correct the following error:</b><br />

    <?php echo $myError; ?>

 

    </body>

    </html>

<?php

exit();

}

?>

Link to comment
https://forums.phpfreaks.com/topic/181267-auto-reply-help-and-other/
Share on other sites

You will need to use the 4th parameter of mail, the headers parameter. To show it as from the person you would use something like...

 

$headers = "From: $email\r\n";

 

... but that isn't really the correct behavior and could cause it to end up in your junk/spam folder. Personally I would recommend...

 

$headers = "Reply-To: $email\r\n";
$headers .= "Return-Path: $email\r\n"; 

 

... that way it will show the e-mail as being from your server, but if you click reply it should send it to the users e-mail.

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.