php Contact Form on website and reply-to email

我怕爱的太早我们不能终老 提交于 2019-11-27 06:22:09

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/3106009/php-contact-form-on-website-and-reply-to-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!