电子邮件表单不发送邮件

时间:2015-08-01 17:15:38

标签: php contact-form

我正在尝试设置我网站的联系表单。 该脚本使用模板contact_me.php。表格的相关摘录在这里:

// 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;

当我填写表格时,它似乎有效;但是,我没有收到任何邮件。

3 个答案:

答案 0 :(得分:1)

命令:

sudo apt-get install sendgmail

完成了工作。它没有安装在我的服务器中。

答案 1 :(得分:0)

所有代码都很好。您应该知道函数mail()在本地服务器运行时不会发送邮件。以下是证明:How to send an email using PHP?

如果你想使用本地服务器发送邮件,你应该使用phpmailer。

编辑:我认为如果你安装hMailServer它将在本地服务器上运行。

答案 2 :(得分:-2)

删除点中的点(.):

$headers .= "Reply-To: $email_address";
相关问题