7

我在我的本地主机服务器上。我在下面使用此代码,但我从未收到过电子邮件。

<?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.";
?>
4

2 回答 2

4

我知道有点晚了...

检查您的本地主机是否配置为发送电子邮件

在 ubuntu 终端上尝试执行以下命令

# apt-get install sendmail
于 2014-11-07T12:05:45.580 回答
3

确保在 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
*/
于 2013-02-10T21:09:36.660 回答