Php Contact form on the site and reply to e-mail

I have a PHP contact form on a site that I find on our mediatemple grid server that was created using 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 just uses the trash / blackhole address. Any way to configure my php, or better yet, server settings, send mail as the response address that the user fills in the contact form itself?

Why? Well, Google hosts email for this domain, and I wanted to use their completed replies as an answering machine. The problem, of course, is that the answering machine is sent to serveradmin@ourdomain.com , and not to the email address of the user that he filled out on the form.

Thanks for the help!

-Hunter

+4
source share
1 answer

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

+3
source

Source: https://habr.com/ru/post/954608/


All Articles