如何从localhost发送邮件

时间:2015-03-16 10:17:32

标签: php

我不能从Localhost发送邮件。 我使用Xampp和我的php.ini和sendmail.ini文件正确配置

我现在可以做什么?

2 个答案:

答案 0 :(得分:1)

您无法使用mail功能从localhost发送邮件。您必须使用SMTP才能发送电子邮件。

检查this有关如何使用SMTP发送电子邮件的信息。

答案 1 :(得分:0)

如果您只需要测试邮件功能而无需连接到互联网,则应使用Papercut这个简单的应用程序来测试发送邮件。您无需进行任何配置。

只需运行它并尝试测试发送邮件即可。

sendmail.php

<?php
     $to = "sampleperson@example.com";
     $subject = "My Subject";
     $txt = "My sample msg.";
     $headers = "From: webmaster@example.com" . "\r\n" .
     "CC: somebodyelse@example.com";

     mail($to,$subject,$txt,$headers);
?>

您将得到这个。 Papercut Inbox

下载Papercut here