Skip to main content
RJweb
Inspiring
September 20, 2009
Answered

auto email response ?

  • September 20, 2009
  • 4 replies
  • 1868 views

good afternoon,

I have a contact page on a site,  name, email address, and message all in PHP

is there a way I can have an auto response email to be sent to the sender, a thank you page is sent when sender clicks send

I know I can use web host to do an auto response, but then that would be all my email that I receive, I strickly want the contact form response

Thx for your help

This topic has been closed for replies.
Correct answer David_Powers

RJweb wrote:

I have a contact page on a site,  name, email address, and message all in PHP

is there a way I can have an auto response email to be sent to the sender, a thank you page is sent when sender clicks send

Adapt your script to send a second email.

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

if (isset($_POST['email'])) {

  // perform a check here to make sure it's an email

  // for example, if you're using PHP 5.2 or above

  $valid = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);

  // after the check, send a message

  if ($valid) {

    mail($_POST['email'], 'Thank you for contacting us',

      'Thank you for your comments. We will be in touch shortly, if necessary.');

  }

}

4 replies

November 26, 2009

I'll like to know from y'all exactly how to design this auto email response program with dreamweaver. I just lunched my site at get traffic website .And I need an auto email response program for my newsletter subscribers.

Participant
November 26, 2009

Hi RJweb,

I found this great free extension that added a contact form with auto response option, thank you/error pages and a refreshable captcha to my site.

http://www.michielvandijk.nl/downloads

David_Powers
David_PowersCorrect answer
Inspiring
September 21, 2009

RJweb wrote:

I have a contact page on a site,  name, email address, and message all in PHP

is there a way I can have an auto response email to be sent to the sender, a thank you page is sent when sender clicks send

Adapt your script to send a second email.

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

if (isset($_POST['email'])) {

  // perform a check here to make sure it's an email

  // for example, if you're using PHP 5.2 or above

  $valid = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);

  // after the check, send a message

  if ($valid) {

    mail($_POST['email'], 'Thank you for contacting us',

      'Thank you for your comments. We will be in touch shortly, if necessary.');

  }

}

RJweb
RJwebAuthor
Inspiring
September 22, 2009

Thx David,

it works, but now I also get 2 emails from my contact form,

name, email, comments

the contact form is from your dw 8 book, your books are always top notch

Thx for your help

David_Powers
Inspiring
September 22, 2009

There should be two calls to the mail() function: one to send the email to you, the other to send the email to the other person. I showed both in my code example. You need to adapt the code to fit your own script.

DwFAQ
Participating Frequently
September 20, 2009

Sure just append the CC address into your script or use a mail client rule to filter what emails get autoreponse. For instance Mail.app on the Mac has a feature called "rules" where you can create a rule that if a condition is met then an action is set.