View Full Version : Resolved Contact form reply

10-29-2012, 08:44 PM
Okay, I'm looking at developing this code.

The problem : The "from" in your inbox is your site, but to do a email auto respond there is not an email to reply to (unless you auto respond to your site), but the email is in the content.

The solution : Get email in content and send to inbox from that person, rather from site.

But how ?

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: TangledDemo';
$to = 'contact@tangledindesign.com';
$subject = 'Hello';
$human = $_POST['human'];

$body = "From: $name\n E-Mail: $email\n Message:\n $message";

if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
} else {
echo '<p>You need to fill in all required fields!!</p>';

10-29-2012, 09:15 PM
I should think before I post.

$from = 'From:'.$_POST['email'].';';


10-29-2012, 09:20 PM
Okay, I've hit a problem.

The email address comes in the inbox as from. When you click reply, it responds to that email.

However when you set up an auto reply it responds to your site because the from email address is layed out like:

From: joe@joebloggs.com via optic.yourhost.com

And then responds to the latter email address, this only on auto response, not manual reply.

Any reason why ?

10-29-2012, 10:15 PM
Add the Reply-To header on the email as well.
You cannot actually send out email from someone else's account without knowing their username and password.

10-29-2012, 11:05 PM
Hey ?

They will email me from joe@joebloggs.com

I want to reply to them automatically as the contact form goes to an email address that is for submissions. So it's a thank-you for your submission, generic response.

I want to reply to their email address they submit, NOT the 'via optic.yourhost.com' bit that is happening at the moment.

10-29-2012, 11:18 PM
$headers = 'From:'.$_POST['email'].'' . "\r\n" .
'Reply-To:'.$_POST['email'].'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

I added that. But it still sends a reply to blah@optic.yourhost.com

10-30-2012, 12:08 AM

$returnpath = "-f" . $_POST['email'];

if (mail ($to, $subject, $body, $headers, $returnpath)) {

It was the bloody additional parameter -f that strips the mail-by and replaces with your variable.

Source: http://php.net/manual/en/function.mail.php

10-30-2012, 12:18 AM
The sendmail didn't obey the from and reply-to headers? On the plus side you've got it sorted, so glad you got it worked out!

10-30-2012, 11:22 PM
The sendmail didn't obey the from and reply-to headers? On the plus side you've got it sorted, so glad you got it worked out!

Still ignored the reply to header and sent to name@host. So stripping the mail-by fixed this and uses reply to header again.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum