views:

26

answers:

1

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

+2  A: 

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

Redlab
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!
Hunter in SD
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?
Redlab
If it's still sending from [email protected] you should take a look at other php email solutions like in http://stackoverflow.com/questions/1872639/good-php-email-library these you can customize more
Redlab
Thanks this solution worked like as is for me! thanks for the help
theGoose