邮件功能没有在本地主机服务器

问题描述:

我我的本地服务器上的工作。我在下面使用此代码,但我从未收到该电子邮件。邮件功能没有在本地主机服务器

<?php 
$to = "[email protected]"; 
$subject = "Test mail"; 
$message = "Hello! This is a simple email message."; 
$from = "[email protected]"; 
$headers = "From:" . $from; 
mail($to,$subject,$message,$headers); 
echo "Mail Sent."; 
?> 
+0

你有没有配置SMTP通过ISP的邮件服务器发送电子邮件? – ceejayoz 2013-02-10 21:09:02

+0

我正在使用XAMMP,你是怎么做到的? – user1995927 2013-02-10 21:11:57

+0

http://expertester.wordpress.com/2010/07/07/how-to-send-email-from-xampp-php/ – ceejayoz 2013-02-10 21:15:03

它可能会工作,一旦你已经安装了一个程序,如nullmailer发送您的邮件。

确保邮件服务器是在php.ini文件中正确配置。

这些线路像这样的php.ini文件注释并重新启动Apache服务器。

/*[mail function] 
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury 
; SMTP = localhost 
; smtp_port = 25 
*/ 

/*; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 
*/ 
+1

你怎么究竟做呢? – user1995927 2013-02-10 21:11:25

+2

http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html – pwolaq 2013-02-10 21:13:35

+0

我与本网站遇到了,但什么实际上他们的意思通过“更改本地主机到您的ISP的SMTP服务器名称”这行SMTP = smtp.wlink.com.np是我弄混淆 – user1995927 2013-02-10 21:15:04

我知道它很晚了...

检查,如果你的本地主机配置为发送电子邮件

在Ubuntu终端 请尝试执行以下命令

# apt-get install sendmail 
+0

谢谢你拯救我的一天 – 2016-09-05 11:12:05