Reputation: 859
I am trying to send a simple email form, everything is working fine, however I keep receiving the recipient email at the end of the body message. I examined the PHP code but I couldn't find why is displaying that email again, here is the PHP code:
$name = $_POST['name'];
$company = $_POST['company'];
$website = $_POST['website'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = '[email protected]';//<== update the email address
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Company: $company.\n".
"Website: $website.\n".
"Contact Email: $visitor_email.\n".
"Here is the message:\n$message.\n".
"\n".
$to = "[email protected]";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
I'm introducing these details in the form:
Name: xxx
Company: xxx
website: www.xxx.com
email: [email protected]
message: Hi testing email
and this is what I am receiving:
You have received a new message from the user Juan Camilo.
Company: Blitzar.
Website: www.stiktag.com.
Contact Email: [email protected].
Here is the message:
Hi, testing website.
[email protected]
The problem is the last line ([email protected]), why am I receiving that address when I already added it to the header, I don't want to see it there, any ideas?
Upvotes: 0
Views: 568
Reputation: 9142
The last line of your $email_body
is concatenating down.
$email_body = "You have received a new message from the user $name.\n".
"Company: $company.\n".
"Website: $website.\n".
"Contact Email: $visitor_email.\n".
"Here is the message:\n$message.\n".
"\n".
Replace the last line: "\n".
with "\n";
- notice the semicolon. This terminates the assignment.
Upvotes: 1