我在本地主机服务器上。我使用下面的代码,但我从未收到过电子邮件。
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
我知道有点晚了。。。
检查本地主机是否配置为发送电子邮件
在ubuntu终端上尝试执行以下命令
# apt-get install sendmail
确保在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 = postmaster@localhost
*/