php Contact Form on website and reply-to email
Asked Answered
D

1

4

I have a PHP Contact form on a site I am hosing on our mediatemple grid server that was made with Rapidweaver. It works well except that the email it generates to our [email protected] is sent as [email protected]. I think the server is just using the trash/blackhole address. Any way to adjust my php or better yet, the server settings, to send the mail as the reply-to address that the user fills out on the contact form itself?

Why? Well Google hosts the email for this domain and I wanted to use their canned responses as an auto-responder. The problem of course, is that the auto-response goes to [email protected] and not the user's email address that he filled in on the form.

Thank you for the help!

-Hunter

Dress answered 23/6, 2010 at 22:26 Comment(0)
E
3

You can add headers to your mail

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

see mail phpdoc

Erato answered 23/6, 2010 at 22:42 Comment(3)
Thanks for the quick reply. The Reply-to is showing in the headers, but Google's Canned responses use the original sender to respond to. I would like for it to respond to the email address that the user fills in. Would I have to adjust this in my php.ini file? Something like: sendmail_from = $emailaddress where $emailaddress is what the user entered on the form. Am I way off base here? Thanks!Dress
no you don't want to change php.ini on the fly. But instead of reply-to put the users mail in the from in $headers? Doesn't that solves it then?Erato
If it's still sending from [email protected] you should take a look at other php email solutions like in stackoverflow.com/questions/1872639/good-php-email-library these you can customize moreErato

© 2022 - 2024 — McMap. All rights reserved.