cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

php mail() not working with Linux cPanel

I have a contact form on my website contact page with the following code

<?php
$name = $_POST['name'];
$mob = $_POST['mob'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "myemail";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You for contacting mywebsite ! <br> We will get back to you shortly.";
?>"

". 

I am receiving blank emails only, without any content and details.

Godaddy customer service guys are giving parroted scripts only. 

Please help ASAP. 

1 REPLY 1
Super User III
Super User III

Re: php mail() not working with Linux cPanel

@pkpkpkpk 

 

I believe you need to split out the variables out side the quotes and join it with .

So it would be 

$formcontent="From: ". $name . "\n Message: " . $message;

Here is example that shows this as well - https://www.freecontactform.com/email_form.php

You would need this for your header as well

 



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community