如何从localhost发送电子邮件到(gmail,yahoo等)

时间:2012-04-27 17:11:31

标签: php

我在Windows环境(WAMP)上想检查我在php中构建的一个应用程序,该应用程序在localhost上发送邮件。请帮助我如何从localhost发送电子邮件

1 个答案:

答案 0 :(得分:0)

我已经在我的本地计算机上运行了这样的系统。 如果我的服务器在线,您可以查看here

我跟着this guide来帮助我度过难关。 除了使用projectpier之外,确保你做了所有事情,你不需要它。你将使用Php发送邮件。

示例Php代码:

$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
    if (mail($mailto, $subject, $message, $header)) {
        echo "Mail successfully sent with given data"; // or use booleans here
    } else {
        echo "Mail sending failed! Please make sure all data is correct and you are connected to the internet";
    }

确保正确设置所有变量