A
Anonymous
Guest
Can anyone please help me to correctly define these header variables? All of the sample code I've founded online does not apply to my situation:
I am trying to correctly format the $headers in my PHP contact form, so that when someone sends me an email from the contact form on my website it is labeled as the "from" address and the "Reply-to" email address in the from header. A snippet labeled ORIGINAL CODE is what was in the original form (that came with a theme that I purchased) and resulted in an error from the server. The solution I've tried is labeled as NEW CODE and now the contact form submits sends successfully, but the header reads as: " $email@MYSERVER.web-hosting.com"
ORIGINAL CODE:
<?php
// Setup our basic variables
$input_name = strip_tags($_POST['name']);
$input_email = strip_tags($_POST['email']);
$input_subject = strip_tags($_POST['subject']);
$input_message = strip_tags($_POST['message']);
//MAIL function
if(mail($your_email_address, $subject, $message, "From: $input_email")) {
NEW CODE
<?php
// Setup our basic variables
$input_name = strip_tags($_POST['name']);
$input_email = strip_tags($_POST['email']);
$input_subject = strip_tags($_POST['subject']);
$input_message = strip_tags($_POST['message']);
$headers = 'From: $email' . "\r\n" .
'Reply-To: $email' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//MAIL function
if(mail($your_email_address, $subject, $message, $headers )) {
The entire code is visible at the following link if you need to see it all to make sense of things. I would be ever so grateful to anyone that could help.
https://docs.google.com/document/d/13kU6jhQHTNGEXPuwvDcoJOLkRX54QeUQbLOS8ir-IAA/edit?usp=sharing
I am trying to correctly format the $headers in my PHP contact form, so that when someone sends me an email from the contact form on my website it is labeled as the "from" address and the "Reply-to" email address in the from header. A snippet labeled ORIGINAL CODE is what was in the original form (that came with a theme that I purchased) and resulted in an error from the server. The solution I've tried is labeled as NEW CODE and now the contact form submits sends successfully, but the header reads as: " $email@MYSERVER.web-hosting.com"
ORIGINAL CODE:
<?php
// Setup our basic variables
$input_name = strip_tags($_POST['name']);
$input_email = strip_tags($_POST['email']);
$input_subject = strip_tags($_POST['subject']);
$input_message = strip_tags($_POST['message']);
//MAIL function
if(mail($your_email_address, $subject, $message, "From: $input_email")) {
NEW CODE
<?php
// Setup our basic variables
$input_name = strip_tags($_POST['name']);
$input_email = strip_tags($_POST['email']);
$input_subject = strip_tags($_POST['subject']);
$input_message = strip_tags($_POST['message']);
$headers = 'From: $email' . "\r\n" .
'Reply-To: $email' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//MAIL function
if(mail($your_email_address, $subject, $message, $headers )) {
The entire code is visible at the following link if you need to see it all to make sense of things. I would be ever so grateful to anyone that could help.
https://docs.google.com/document/d/13kU6jhQHTNGEXPuwvDcoJOLkRX54QeUQbLOS8ir-IAA/edit?usp=sharing