PHP email function not working on vps that used VestCP as control panel

Viewed 14

Consider the PHP script as in the test.php file:

<?php
include_once('internal/Smarty.class.php');
$main_smarty = new Smarty;

include('config.php');
include(KAHUK_LIBS_DIR . 'smartyvariables.php');

$email = '...@gmail.com';
$subject = $main_smarty->get_config_vars('KAHUK_PassEmail_Subject_verification');

$message = $main_smarty->get_config_vars('KAHUK_PassEmail_verification_message');

$fromEmail = $main_smarty->get_config_vars('KAHUK_LANG_EMAIL_NOREPLY');
$replyToEmail = $main_smarty->get_config_vars('KAHUK_LANG_EMAIL_NOREPLY');

$headers = [];
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';

$headers[] = 'From: Vahuk Noreply <' . $fromEmail . '>';

ini_set("SMTP", "server.mydomain.com");
ini_set("sendmail_from", $fromEmail);

$headers = implode("\r\n", $headers);

if (mail($email, $subject, $message, $headers)) {
    echo "Check your email now....";
} else {
    echo "Error";
}

I am running a VPS, using the VestCP control panel.

When browsing the test.php file, it shows Check your email now..... But the email never reaches my email address!!

0 Answers
Related