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 info@ourdomain.com is sent as serveradmin@ourdomain.com. 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 serveradmin@ourdomain.com and not the user's email address that he filled in on the form.

Thank you for the help!

-Hunter

Hunter in SD
  • 79
  • 2
  • 7

1 Answers1

3

You can add headers to your mail

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

see mail phpdoc

Redlab
  • 3,110
  • 19
  • 17
  • 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 Jun 23 '10 at 22:52
  • 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 Jun 23 '10 at 23:07
  • If it's still sending from serveradmin@yourdomain.com 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 Jun 23 '10 at 23:10