This question already has an answer here:
I'm trying to write a code to send emails from a contact form, I'm doing tests on a ubuntu server and here is the php config on this server:
And here is my php code (I've tested this same code in other online production server and works perfectly):
<?php $ToEmail = 'firstname.lastname@example.org'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]." "; $mailheader .= "Reply-To: ".$_POST["email"]." "; $mailheader .= "Content-type: text/html; charset=iso-8859-1 "; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?>
This code isn't working on my Ubuntu server, what can I do? I don't want to use libraries. I read that in Linux server there is no need to install anything and no need to add a SMTP configuration on the code, even in the php manual give some basics examples to send emails and those don't have any SMTP code. What is the problem with this code?