我已经创建了PHP应用程序并使用heroku进行部署.在应用程序中,我有联系表单将邮件发送到我的Gmail帐户.为实现这一点,我编写了以下PHP代码
<?php
$to = "to@gmail.com";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:from@yantranet.com \r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ){
echo "Message sent successfully...";
}else{
echo "Message could not be sent...";
}
?>
Run Code Online (Sandbox Code Playgroud)
我的php脚本正在执行.但它并没有发送邮件而是出现了Message could not be sent.任何人都可以帮助使用PHP实现联系表单吗?