Page 1 of 1

contact form email

Posted: Tue Apr 27, 2010 3:46 pm
by Stefan83
Hi

I'm having difficulties sending the contents from a contact form to the body of an email.

The email delivers no problem, but only the message is displayed in the body, I'd like to include the email address, name and telephone of the sender in the body of the email.

Could someone please shed some light on this? thanks!

Code: Select all

<?php
ini_set("sendmail_from", "mail@myemail.com");

$to = "mail@myemail.com";
$name = $_POST['name'];
$email_from =$_POST['email'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$message = $_POST['message'];

$subject = "Subject";
$body = "From $name, $telephone, $email, \n\n$message, \n\n$name";
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";

mail($to, $subject, $body, $name);

$sent = mail($to, $subject, $message, $headers, '-f'.$email_from);
?>


Re: contact form email

Posted: Tue Apr 27, 2010 3:59 pm
by Christopher

Code: Select all

$sent = mail($to, $subject, $body, $headers, '-f'.$email_from);

Re: contact form email

Posted: Tue Apr 27, 2010 4:12 pm
by Stefan83
Perfect! Thanks Christopher

Re: contact form email

Posted: Wed Apr 28, 2010 12:13 pm
by Stefan83
I have one more question. How would I setup an auto response after the email from the contact form has been delivered? Or would it be possible for the user to click a check box to request a copy of the email they send via the contact form? Thanks in advance!

Re: contact form email

Posted: Wed Apr 28, 2010 4:17 pm
by Jonah Bron
[syntax="php]if ($_POST['send_copy_to_me'] == '1'){
$sent_to_self = mail($email_from, $subject, $body, $headers, '-f'.$email_from);
}[/syntax]

Just plop a checkbox into your form page.

Code: Select all

<input type="checkbox" name="send_copy_to_me" value="1" />