0

The sendmail works locally but I'm not sure why it isn't working on Heroku. The application log is attached below.

sendmail program:

<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;
}

Application log on Heroku

0 Answers0