我在Windows环境(WAMP)上想检查我在php中构建的一个应用程序,该应用程序在localhost上发送邮件。请帮助我如何从localhost发送电子邮件
答案 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";
}
确保正确设置所有变量