php - herokku 中的 PHPmailer 邮件程序给出 HTTP ERROR 500
问题描述
我编写了一个代码,它使用带有 phpmailer 的 SMTP gmail 发送邮件。它在我的本地主机上运行良好。但是当我在 heroku 中部署代码时,它给出了
royalmarutiservices.herokuapp.com is currently unable to handle this request.
HTTP ERROR 500
这是heroku的日志 https://pastebin.com/raw/AgY11dBB
<?php
//echo $_POST['email'].$_POST['fname'].$_POST['phone'].$_POST['subject'];
include_once('PHPMailer/src/PHPMailer.php');
include_once('PHPMailer/src/SMTP.php');
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "user@gmail.com";
$mail->Password = "pass";
$mail->SetFrom($_POST['email']);
$mail->Subject = " Message from ".$_POST['fname'];
$mail->Body = $_POST['message'];
$mail->AddAddress('royalmaruti1996@gmail.com');
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
header('Location:index.php');
?>
关于 phpinfo() 的详细信息 ~ https://royalmarutiservices.herokuapp.com/info.php
解决方案
推荐阅读
- python - 如何将两个定义的功能重复 5 次?Python
- mysql - 获取两个日期时间段之间的数据库搜索结果
- excel - 使用未识别的 laravel 标题导入 Excel 文件
- jquery - 延迟jQuery中的点击功能
- ansible - 在 Ansible 中设置来宾操作系统自定义规范的参数
- javascript - babel-plugin-module-resolver 不适用于节点中的 eslint
- sql-server - 无法加载文件或程序集 Microsoft.SqlServer.SMO
- sql - 从 SQLPlus 运行 SQL 脚本失败时如何查看错误?
- javascript - 在不使用 async await 关键字的情况下等待 promise 的值?
- javascript - 修改函数以使名称也链接