php - sendmail 在 localhost 中有效,但在 heroku 中无效
问题描述
sendmail 在本地工作,但我不确定为什么它不能在 Heroku 上工作。应用程序日志附在下面。
发送邮件程序:
<section class="container grey-text">
<h4 class="center">2-Step Verification</h4>
<script defer src= "2-StepScript.js"></script> <!--javascript script for 2-step verification page-->
<?php
$code = "";
function generateKey() //generates the key to be sent to user
{
$keyLength = 8;
$characters = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$randomStr = substr(str_shuffle($characters), 0, $keyLength);
return $randomStr;
}
function sendEmail() //send email to user
{
$to_email = $_SESSION['email'];
$subject = "2-Step Verification";
$message = "Hi " . $_SESSION['firstName'] . ".\n\nThis is your 2-step verification number: ";
$header = "From: OCCSS";
$sCode = generateKey();
$body = $message . $sCode;
if (mail($to_email, $subject, $body, $header))
{
echo "Email successfully sent to $to_email...";
}
else
{
echo "Email sending failed...";
}
return $sCode;
}
解决方案
推荐阅读
- powershell - 如何使更新 Windows 10 PS 脚本在重新启动后恢复并使用结果更新 CSV 文件?
- pyspark - 无法解析带有流源的查询必须使用 writeStream.start() 结构化 Spark Streaming - Pyspark 执行
- reactjs - 在测试期间无法访问组件中的 DOM 元素(在浏览器中工作)
- java - 从 Dataflow 作业创建云 sql 表
- java - 底部导航徽章编号阿拉伯文
- networkx - 从 NetworkX 在 StellarGraph 中分配边缘特征
- python - scipy.optimize.minimize 约束问题
- angular - Angular:更新表单......奇怪的行为
- swift - 创建的边界框的深度不正确
- javascript - 使用 JSX 的地图时如何避免卸载子组件?