首页 > 解决方案 > 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

标签: phpemailheroku

解决方案


推荐阅读