1

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.\n\n"."Here 
are the details:\n\nName: $name\n\nPhone: $phone\n\nEmail: 
$email_address\n\nMessage:\n$message";
$headers = "From: noreply@ecopoliticas.com\n";
$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.

spongebob
  • 8,370
  • 15
  • 50
  • 83
jalp2000
  • 21
  • 4
  • Welcome to Stack Overflow! Congratulations, you have formatted the code properly! Unfortunately, you forgot to add the language tag. I think this is PHP, am I right? I've cleaned the question to make it more readable and upvoted to encourage you keeping up the good work. – spongebob Aug 03 '15 at 17:50

3 Answers3

1

The command:

sudo apt-get install sendgmail

did the work. It was not installed in my server.

jalp2000
  • 21
  • 4
0

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.

Community
  • 1
  • 1
-2

Remove the dot (.) in:

$headers .= "Reply-To: $email_address";
spongebob
  • 8,370
  • 15
  • 50
  • 83