I'm trying to set up the contact form of my site. The script uses the template contact_me.php
. The relevant excerpt of the form here:
// create email body and send it
$to = 'jose.alberto.lara@gmail.com'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Contacto con Ecopolíticas: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.
"."Here
are the details:
Name: $name
Phone: $phone
Email:
$email_address
Message:
$message";
$headers = "From: noreply@ecopoliticas.com
";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
When I fill the form it seems to work; however, I don't receive any mail.
Remove the dot (.
) in:
$headers .= "Reply-To: $email_address";
Everything with code is fine. You should know that function mail() won't send mail when it is run by local server. Here is proof: How to send an email using PHP?.
If you want to send mail even with local server you should use phpmailer.
EDIT: Also I think if you install hMailServer it will work on local server.
The command:
sudo apt-get install sendgmail
did the work. It was not installed in my server.