Link to home
Start Free TrialLog in
Avatar of Jorge Batres
Jorge BatresFlag for United States of America

asked on

Problem sending emails using PHP script after moving to new server

Hi, I just transferred my sites to a new hosting, and now one of my email functions is not working. This function is in my main administration index page, and I use that file to send emails to different recipients. All the emails work just fine except for a section called "reservation_request". This section is in two different parts of the script:


case "reservation_request":
            $head = "MIME-Version: 1.0\n". //old
                                    "Content-type: text/html; charset=UTF-8\n". 
                              "Return-Path: $_POST[from]\n". 
                                        "From: VacationPeople.Com <$_POST[from]>\n". 
                                    "Date: ".date("r")."\n"; //old
                   include_once(LEVEL."inc/emailer/emailer.php");
                                //mail($_POST['to'], $_POST['subject'], $_POST['content'],$head, "-f " . $_POST['from']);
                                mail("reservation_request",$_POST);

Open in new window

and 

case "reservation_request":
                        $record = $reservation->getRecord();
                        $res = $reservation->showRecord($record,$reservation->lists);
                        $res = array_merge(array(
                            array( "name" => "Source_Code",
                            "title" => "Source Code",
                            "value" => $reservation->lists["Source_Code"]),
                            array( "name" => "request_email",
                            "type" => "hidden",
                            "value" => $reservation->lists["request_email"])
                            ),$res);
                        $res = unsetFields($res,'Card_Number,Card_Expiration,Card_Holder,I_Agree,html');
                        $smarty->assign("reservation", $res);

Open in new window

Can someone please take a look at this and help me figure this out?

Avatar of Scott Fell
Scott Fell
Flag of United States of America image

What does the code that is working look like?

Is this correct?  What is, "LEVEL"? 
include_once(LEVEL."inc/emailer/emailer.php"); 

Open in new window

Avatar of Jorge Batres

ASKER

It works for other emails sent from this script. I'm not sure about LEVEL as this is an old script that I had made back in 2005 and over the years I have been updating it as PHP progresses to new versions.
This is a section that is working:
case "send_change_status":
                        
$head = "MIME-Version: 1.0\n". //old
"Content-type: text/html; charset=UTF-8\n". 
                              "Return-Path: $_POST[from]\n". 
"From: VacationPeople.Com <$_POST[from]>\n". 
"Date: ".date("r")."\n"; //old
include_once(LEVEL."inc/emailer/emailer.php");
mail($_POST['to'], $_POST['subject'], $_POST['content'],$head, "-f " . $_POST['from']);
break;

Open in new window

and this is also on the script:
case "change_status":
$data = fetchArray($_POST,"status");
$res = $reservation->getByID($_REQUEST["id"]);
include_once(LEVEL."inc/emailer/emailer.php");
SendEmail("change_status",$res, false);
require_once ($spaw_root .'spaw_control.class.php');
//$spaw = & new SPAW_Wysiwyg('content', $body,'en',
$spaw = new SPAW_Wysiwyg('content', $body,'en',// new PHP 7 removed &
'default', 'default', '100%', '500px', '','');
$smarty->assign('spaw', $spaw->getHTML());
$smarty->assign("email", $email);
break;

Open in new window


What I am getting at is where you have LEVEL, that should be preceded by a DEFINE statement. like

https://www.php.net/manual/en/function.define.php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."

Open in new window


Do you have LEVEL defined on that page?

There is something happening I believe beyond what you are showing. Take a look at your PHP logs for some clues.
Always consult the log.
Are you using the local MTA?
Tail /var/log/maillog
Check whether there are edge firewall rules that exist to allow yen old serer external access to destinations over port 25

Can you make an outgoing port 25 connection?
1) What you're describing sounds like your old hosting was sending email natively, in other words, a local MTA was actually sending email.

This generally produces very low delivery/inboxing of email.

2) Now new hosting is much more sensible, providing no native MTA... because... native MTAs only work if you maintain them, which is a full time job.

3) The fix is likely to setup an account with a Mail Relay, like MailGun, so all your mail is 587 authenticated submitted to a MailGun server for delivery.

4) This is simple to verify. You'll root ssh into your machine + check to see if there's an MTA running + how it's configured.

Tip: If you haven't spent many hours setting up your native MTA + testing SMTP response codes against DMARC reports, then either you have no MTA running or all email sent from your MTA will be blocked before submission.

Your MTA logs (if an MTA is running) will tell you instantly any MTA problems.

5) Using a Relay like MailGun will be your cheapest alternative.
I am hosting my sites in the cloud (SiteGround) and I don't have access to logs as I used to have. They say no errors regarding mail.

here are the two files that I use for sending the emails. Please note that the only case that is not working is on lines 138 and 295 of the index.php script case "reservation_request":
<?php
error_reporting(E_ALL);
ob_start();
define ("LEVEL", "../");
include_once(LEVEL."inc/include.php");

//OpenSSL Class


//End OpenSSL Class

$spaw_dir = '/admin/spaw/';
$spaw_root = _FULL_PATH .'admin/spaw/';

$admin = new admins();
$reservation = new reservation();
//$reservation = $reservation->reservations();
session_start();

$error = (isset($_SESSION["error"])) ? ($_SESSION["error"]) : ("");
$message = (isset($_SESSION["message"])) ? ($_SESSION["message"]) : ("");

$clientview = false;


if ($_REQUEST["section"] == 'login') {


    if ($message != '') $smarty->assign("message", $message);
    if ($error != '') $smarty->assign("error", $error);
    $smarty->assign("content", 'admin/login.html');
    $smarty->display("index.html");
    unset($_SESSION['error']);
    unset($_SESSION['message']);
    exit();
} else if ($_REQUEST["section"] == "reservation_view" and isset($_REQUEST["id"]) and isset($_REQUEST["key"]) and $_REQUEST["key"] == sha1($_REQUEST["id"] . "padding123")){
    $clientview = true;
} else {

    if ($admin->CheckLogin("index.php?section=login")) {


        //header("Location: $_SERVER[PHP_SELF]");
    }

}

//dump($_SESSION);
//dump($_REQUEST);
//dump($);

$menu = array(
"user_info"=>"Admin Info",
"reservations"=>"Reservations",
"reservations_archived"=>"Archived",
"reservations_search"=>"Search",
"logout"=>"Logout"
);

$section = ($_REQUEST["section"]) ? ($_REQUEST["section"]) : ("user_info");
$mode = getMode();
$action = ($_REQUEST["action"]) ? ($_REQUEST["action"]) : ("");
$message = '';

if ($mode != '') {
    if (($section=="reservations") || ($section=="reservation_edit" && $mode=="delete")) {
        $action = "reservation_".$mode;
        if ($mode=="delete") $section = "reservations";
    }
}

if ($action != '') {
        switch($action) {
                case "update_myinfo":
                        $data = $_POST;
                  //
// Amended this block for hashing
//
                        if ($data["password"] == ''){
                     unset($data["password"]);
                  }
                  else{
                     $data["password"] = password_hash($data["password"], PASSWORD_DEFAULT);
                  }

//
// End
//
                        //if ($data["password"] == '') unset($data["password"]);
                        $admin->edit($data,$_SESSION["current_user"]["admin_id"]);
                        $admin->reloadPersonalInfo();
                break;
                case "user_add":
                        $user->add($_POST);
                break;
                case "user_edit":
                        $data = $_POST;
                        if ($data["password"] == '') unset($data["password"]);
                        $user->edit($data,$_REQUEST["user_id"]);
                break;
                case "user_delete":
                        $user->delete($_REQUEST["user_id"]);
                break;
                case "reservation_add":
                        $data = $_POST;
                        $reservation->add($data);
                break;
                
                
                case "reservation_delete":
                        $reservation->delete($_REQUEST["id"]);
                break;
                case "send_notify":
                        
                        $head = "MIME-Version: 1.0\n". 
                                    "Content-type: text/html; charset=UTF-8\n". 
                                                        
                                          "Return-Path: $_POST[from]\n". 
                                          "From: domain.Com <$_POST[from]>\n". 
                                           //"From: ".$_POST['from']." <".$_POST['from'].">\r\n". 
                                    "Date: ".date("r")."\n"; // old
                   include_once(LEVEL."inc/emailer/emailer.php");
                     // SendEmail($_POST['from'],$_POST['to'],$_POST['subject'],$_POST['content']); 
              mail($_POST['to'], $_POST['subject'], $_POST['content'],$head, "-f " . $_POST['from']); 
                        break;
                case "send_change_status":
                        
                        $head = "MIME-Version: 1.0\n". //old
                                    "Content-type: text/html; charset=UTF-8\n". //old
                                                         
                                          "Return-Path: $_POST[from]\n". //old
                                           "From: domain.Com <$_POST[from]>\n". // old
                                    "Date: ".date("r")."\n"; //old
                   include_once(LEVEL."inc/emailer/emailer.php");
                        //SendEmail($_POST['from'],$_POST['to'],$_POST['subject'],$_POST['content']);
              mail($_POST['to'], $_POST['subject'], $_POST['content'],$head, "-f " . $_POST['from']);
                        break;
                case "reservation_request":
            
                    
                        include_once(LEVEL."inc/emailer/emailer.php");
                  
                        if($_POST["form_type"] == "westgate-lakes"){
                                mail("westgate-lakes_reservation_request", $_POST);
                        }
                  
                  
                  elseif($_POST["form_type"] == "westgate-villas"){
                                mail("westgate-villas_reservation_request", $_POST);
                        }
                  
                  elseif($_POST["form_type"] == "westgate-town-center"){
                                mail("westgate-town-center_reservation_request", $_POST);
                        }
                  
                  
                  elseif($_POST["form_type"] == "westgate-palace"){
                                mail("westgate-palace_reservation_request", $_POST);
                        }
   
                  
                        elseif($_POST["form_type"] == "branson-woods"){
                                mail("branson-woods_reservation_request", $_POST);
                        }
                  
                  
                        elseif($_POST["form_type"] == "river-terrace"){
                                mail("river-terrace_reservation_request", $_POST);
                        }
                  
                  
                        elseif($_POST["form_type"] == "westgate-myrtle-beach"){
                                mail("westgate-myrtle-beach_reservation_request", $_POST);
                        }
                  
                  
                        elseif($_POST["form_type"] == "westgate-smoky-mountain"){
                                mail("westgate-smoky-mountain_reservation_request", $_POST);
                        }
                  
                  
                        elseif($_POST["form_type"] == "westgate-las-vegas"){
                                mail("westgate-las-vegas_reservation_request", $_POST);
                        }
                  
                  
                        elseif($_POST["form_type"] == "westgate-williamsburg"){
                                mail("westgate-williamsburg_reservation_request", $_POST);
                        }

                                    
            
                        elseif($_POST["form_type"] == "roberts-grove-beach"){
                                mail("roberts-grove-beach_reservation_request", $_POST);
                        }
                  
                  
                        else {
                                mail("reservation_request",$_POST);
                        
                        }
            
                  
                        //change_status
                        $data = array(
                                 'status' => 'In Process',
                                 'date_request_sent' => date("F j, Y g:i a"),
                              );
                    
            
                        $reservation->edit($data, $_REQUEST["id"]);
                        $res = $reservation->getByID($_REQUEST["id"]);
                        //include_once(LEVEL."inc/emailer/emailer.php");
                        //SendEmail("change_status",$res);
                        break;


                case "to_archive":
                        $data = array();
                        $data['archived'] = 1;
                        $data['archived_date'] = date("Y-m-d H:i:s");
                        $reservation->edit($data, $_REQUEST["id"]);
                        $section = "reservations";
                break;
                case "from_archive":
                        $data = array();
                        $data['archived'] = 0;
                        $reservation->edit($data,$_REQUEST["id"]);
                        $section = "reservations";
                break;
                

        }
        if ($action != "search") {
            header("Location: index.php?section=$section");
        }
}


        switch ($section) {
                case "user_info":
                break;
                case "myinfo_edit":
                        $myinfo = $admin->getByID($_SESSION["current_user"]["admin_id"]);
                        unset($myinfo["password"]);
                        $smarty->assign("user", $myinfo);
                break;
                case "reservations":
                        $smarty->assign("reservations", $reservation->getWhere("archived != 1".$where));
                break;
                case "reservations_archived":
//                        ini_set("memory_limit", "80M");
                        $smarty->assign("reservations", $reservation->getWhere("archived = 1".$where, "archived_date desc"));
                break;
                
                case "reservation_status":
                        $record = $reservation->getRecord();
                        $need = "id,status";
                        $record = fetchArray($record,$need);
                              $res = fetchFields($reservation->showRecord($record,$reservation->lists),$need);
                        $smarty->assign("reservation", $res);
                break;
                case "change_status":
                        $data = fetchArray($_POST,"status");
                        $reservation->edit($data,$_REQUEST["id"]);
                        $res = $reservation->getByID($_REQUEST["id"]);
                        include_once(LEVEL."inc/emailer/emailer.php");
                        SendEmail("change_status",$res, false);
                        require_once ($spaw_root .'spaw_control.class.php');
                        //$spaw = & new SPAW_Wysiwyg('content', $body,'en',
         $spaw = new SPAW_Wysiwyg('content', $body,'en',// new PHP 7 removed &
                        'default', 'default', '100%', '500px', '','');
                        $smarty->assign('spaw', $spaw->getHTML());
                        $smarty->assign("email", $email);
                break;
                case "send_notify":
                        $record = $reservation->getRecord();
                        $need = "id,status,code";
                        $record = fetchArray($record,$need);
                        $res = fetchFields($reservation->showRecord($record,$reservation->lists),$need);
                        $smarty->assign("reservation", $res);
                break;
                case "preview_notify":
                        $reservation->edit($_POST,$_REQUEST["id"]);
                        $record = $reservation->getRecord();
                        include_once(LEVEL."inc/emailer/emailer.php");
                        $record["password"] = substr(sha1($record["id"]), 3, 6);
                        SendEmail("confirm_".$record['form_type'],$record,false);
                        require_once ($spaw_root .'spaw_control.class.php');
                        $spaw = new SPAW_Wysiwyg('content', $body,'en',// removed & PHP 7
                        'default', 'default', '100%', '500px', '','');
                        $smarty->assign('spaw', $spaw->getHTML());
                        $smarty->assign("email", $email);
                break;
                case "reservation_request":
                        $record = $reservation->getRecord();
                        $res = $reservation->showRecord($record,$reservation->lists);
                        $res = array_merge(array(
                            array( "name" => "Source_Code",
                            "title" => "Source Code",
                            "value" => $reservation->lists["Source_Code"]),
                            array( "name" => "request_email",
                            "type" => "hidden",
                            "value" => $reservation->lists["request_email"])
                            ),$res);
                        $res = unsetFields($res,'Card_Number,Card_Expiration,Card_Holder,I_Agree,html');
                        $smarty->assign("reservation", $res);
                break;
                case "reservation_del_card":
                        $record = $reservation->getRecord();
                        $need = "id,First_Name,Last_Name,Card_Type,Card_Holder,Card_Number,Card_Expiration";
                        $record = fetchArray($record,$need);
                        $res = fetchFields($reservation->showRecord($record,$reservation->lists),$need);
                        $smarty->assign("reservation", $res);
                break;
                case "reservations_search":
                        $reservation->loadFields('all');
                        $res = $reservation->showRecord(array(),$reservation->lists);
                        $res = array_merge(array(
                            array( "name" => "archived",
                            "title" => "In Archive",
                            "type" => "radio",
                            "value" => "0",
                            "list" => array("1"=>"Yes","0"=>"No"))
                            ),$res);
                        $res = unsetFields($res,'I_Agree,html');
                        $smarty->assign("reservation", $res);
                break;
                case "logout":
                session_unset();
                session_destroy();
                header("Location: index.php?section=login");
                break;
        }
        $content = _ADMIN_DIR.$section.".html";

if ($message != '') $smarty->assign("message", $message);
if ($error != '') $smarty->assign("error", $error);
$smarty->assign("start", $start);
$smarty->assign("content", $content);
$smarty->assign("menu", $menu);

$smarty->display(_ADMIN_DIR."index.html");
unset($_SESSION['error']);
unset($_SESSION['message']);
?>

Open in new window

and this is the email template that I use for that case:
From: domain.Com <reservations@domain.com> 
To: [request_email] 
Subject: Reservation request from [Source_Code] - [First_Name] [Last_Name]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
   <title>Reservation Status Update</title>
   <style type="text/css">
      #outlook a {padding:0;} 
      body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;}
      
      .ExternalClass {width:100%;} 
      .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} 
      #backgroundTable {margin:0; padding:0; width:100% !important; line-height: 100% !important;}

      img {outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;}
      a img {border:none;}
      .image_fix {display:block;}

      p {margin: 1em 0;}

      h1, h2, h3, h4, h5, h6 {color: black !important;}
      h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {color: blue !important;}
      h1 a:active, h2 a:active,  h3 a:active, h4 a:active, h5 a:active, h6 a:active {
         color: red !important; 
       }
      h1 a:visited, h2 a:visited,  h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited {
         color: purple !important; 
      }

      table td {border-collapse: collapse;}

      table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }

      a {color: blue;}

      @media only screen and (max-device-width: 480px) {

         a[href^="tel"], a[href^="sms"] {
                  text-decoration: none;
                  color: black; 
                  pointer-events: none;
                  cursor: default;
               }
         .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
                  text-decoration: default;
                  color: orange !important; 
                  pointer-events: auto;
                  cursor: default;
               }
      }
      
      @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {

         a[href^="tel"], a[href^="sms"] {
                  text-decoration: none;
                  color: blue;
                  pointer-events: none;
                  cursor: default;
               }
         .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
                  text-decoration: default;
                  color: orange !important;
                  pointer-events: auto;
                  cursor: default;
               }
      }
      @media only screen and (-webkit-min-device-pixel-ratio: 2) {
         
      }

      @media only screen and (-webkit-device-pixel-ratio:.75){
         
      }
      @media only screen and (-webkit-device-pixel-ratio:1){
         
      }
      @media only screen and (-webkit-device-pixel-ratio:1.5){
         
      }
      
   </style>

</head>
<body>

   <table  bgcolor="#FFFFFF"  cellpadding="10" cellspacing="0" border="0" align="center" id="backgroundTable">
     <tr>
      <td>
<table cellpadding="0" cellspacing="0" border="0" align="center" >
         
      
      
  
  <tr>
    
    <td>
      <table bgcolor="#FFFFFF" cellpadding="10" cellspacing="0" border="1">
      <tr>
        <td bgcolor="#FFE29E" colspan="2"><h4 style="text-align:center">New Reservation From [Source_Code]<br><br> 
         Office: 000-207-000 - Fax : 000-965-000 - After Hours / Weekends / Holidays: 000-000-000</h4>
        </td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Source Code: </b>[Source_Code]</td>
           <td width="400"  valign="top"><b>Best Time to Call:  </b>[Call_Time]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Package Price: </b>$[Price]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Check-In Date :  </b>[Checkin_Date]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>First Name: </b>[First_Name]</td>
           <td width="400"  valign="top"><b>Checkout-Date :  </b>[Checkout_Date]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Last Name: </b>[Last_Name]</td>
          <td width="400" bgcolor="#ebebeb" valign="top"><b>Hotel:  </b>[Hotel]</td>
        </tr>        
<tr>
           <td width="400"  valign="top"> <b>Spouse Name: </b>[Spouse_Name]</td>
           <td width="400"  valign="top"><b>Resort:  </b>[Resort]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Marital Status: </b>[Marital_Status]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Room Type:  </b>[Room_Type]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Husband's Occupation: </b>[Husband_Occupation]</td>
           <td width="400"  valign="top"><b>Nights:  </b>[Nights]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Wife's Occupation: </b>[Wife_Occupation]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Tickets:  </b>[Tickets]</td>
        </tr> 
<tr>
           <td width="400"  valign="top"> <b>Address: </b>[Address]</td>
           <td width="400"  valign="top"><b>Number of Guest:   </b>[Guest]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>City: </b>[City]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Adults (18+):  </b>[Adults]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>State: </b>[State]</td>
           <td width="400"  valign="top"><b>Juniors (12 - 17):  </b>[Juniors]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Province: </b>[Province]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Children (Under 12):  </b>[Children]</td>
        </tr> 
<tr>
           <td width="400"  valign="top"> <b>Zip Code: </b>[Zip_Code]</td>
           <td width="400"  valign="top"><b>Income:  </b>[Income]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Country: </b>[Country]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Age:  </b>[Age]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Day Phone: </b>[Day_Phone]</td>
           <td width="400"  valign="top"><b>Card Type:  </b>[Card_Type]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Night Phone: </b>[Night_Phone]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Card Expiration:  </b>&nbsp;</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Email: </b>[Email]</td>
           <td width="400"  valign="top"><b>Name on card:  </b>&nbsp;</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>FAX: </b>[Fax]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Comments:  </b>[Comments]</td>
        </tr>
        <tr>
        <td colspan="2"><h4 style="text-align:center">domain.com<br><br>
domain.com</h4>
        </td>
        </tr>
        


        </table>
    </td>
  </tr>


      </table>
</td>
             
   </tr>
   </table>

</body>
</html>

Open in new window

I really appreciate any help as this is a production server and for the moment I can't request anything using that section of the script.
Thank you, David, what I don't understand is why the script is able to send emails from a different case on the same script and same type of email template as in "send_change_status" in line 126 and "change_status" in line 263. Maybe if I can modify those sections I should be able to make them work
I am going to keep going with this hunch. Are the files all on the same folder level?

What if you change this line
define ("LEVEL", "../");

Open in new window

and set the full path instead of, "../" ?
Actually, if that works in one, it should work for all because it is in the same include file.

What about this line,
 else if ($_REQUEST["section"] == "reservation_view" and isset($_REQUEST["id"]) and isset($_REQUEST["key"]) and $_REQUEST["key"] == sha1($_REQUEST["id"] . "padding123")){     $clientview = true;

Open in new window

Is the template supposed to meet this criteria?

Try outputting those variables before the email runs and see if the criteria is being met.
Yes it does as that line is used to display reservation information that I can see in my browser; so that line doesn't send any emails, it is just to display a record and it works perfectly
Where in that include file will this file be hitting then? Let's look for what can be tripping this up?
This is the content of the include.php file
<?php

define ("INCLUDE_DIR", LEVEL."inc/");
define ("APPLICATION_DIR", "application/");

require (INCLUDE_DIR.'config.php');

require (SMARTY_DIR.'Smarty.class.php');
require (INCLUDE_DIR.'smarty_local.class.php');
//require (INCLUDE_DIR.'functions.php');
require ('/home/customer/www/share/inc/functions.php');
require (INCLUDE_DIR.'smarty.functions.php');
require (INCLUDE_DIR.'db.php');

$handle = opendir(INCLUDE_DIR.APPLICATION_DIR);

while (false !== ($file = readdir($handle))) {
        if (preg_match('/.php$/', $file)) {
            include_once (INCLUDE_DIR.APPLICATION_DIR.$file);
    }
}

require (INCLUDE_DIR.'initialization.php');
?>

Open in new window

I found an error file on the script directory
[11-Jan-2022 14:57:46 UTC] PHP Warning:  mail() expects at least 3 parameters, 2 given in /home/customer/www/domain.com/public_html/reservations/admin/index.php on line 234

Open in new window

and the line is:
mail("reservation_request",$_POST);

Open in new window

Hopefully, this will help 
I am sorry, I meant your index page.

You said, the line, "case "reservation_request": is not working.  

Can you test that, "reservation_request" is in fact being passed as you expect?
What is being passed in $_POST["form_type"]? that is not working?
Is everything in the $_POST being passed as expected to send out the email?

Then on the 2nd case,
 case "reservation_request":
        $record = $reservation->getRecord();
        $res = $reservation->showRecord($record, $reservation->lists);
        $res = array_merge(array(
            array(
                "name" => "Source_Code",
                "title" => "Source Code",
                "value" => $reservation->lists["Source_Code"]
            ) ,
            array(
                "name" => "request_email",
                "type" => "hidden",
                "value" => $reservation->lists["request_email"]
            )
        ) , $res);
        $res = unsetFields($res, 'Card_Number,Card_Expiration,Card_Holder,I_Agree,html');
        $smarty->assign("reservation", $res);

Open in new window


Are each of the variables being set as expected?  $record, $res etc. 
and the line is:
mail("reservation_request",$_POST);

Open in new window


That is why I asked if each of the $_POST items are being output as you expect.   Before that line, do a print_r($_POST) and see what you get and how it fits in with that your code is expecting.
I got this
[11-Jan-2022 15:22:15 UTC] PHP Parse error:  syntax error, unexpected 'mail' (T_STRING) in /home/customer/www/domain.com/public_html/reservations/admin/index.php on line 235

Open in new window

Any idea how I can modify this line to make the script send the email template as it used to?
mail("reservation_request",$_POST);

Open in new window

As @Scott mentioned, likely best to just dump the data first, as he mentioned...

print_r($_POST)

Open in new window


Likely something will jump out as a clue to resolving this problem.

And... you must resolve your sending first, as no amount of work will fix the underlying sending... other than configuring a Mail Relay or Native MTA...

Fix sending first, then work on other problems.
If you look in your code at the top here https://www.experts-exchange.com/questions/29231313/Problem-sending-emails-using-PHP-script-after-moving-to-new-server.html#a43377843 

You have the functions mail and sendmail where in some cases you have sendmail commented out but later in the code you are using sendmail?

syntax error, unexpected 'mail'  
why did you comment out sendmail? Try and go back through your code and instead of commenting out things, save the file as a back up somewhere, then start deleting where you comment things out and use either "mail" or "sendmail" but not both.  It will be cleaner and easier to read through that way. It seems like this is progress though!


I added print_r($_POST) but nothing happens when I execute the script, and I keep getting this warning:

[11-Jan-2022 17:29:05 UTC] PHP Warning:  mail() expects at least 3 parameters, 2 given in /home/customer/www/domain.com/public_html/reservations/admin/index.php on line 235

Open in new window

I'm lost 
the other cases for sending emails are working perfectly though 
I tend to check before getting to deep into the issue, what are you passing, are you passing info directly from a form into a process that send an email out?
Which mode are you using?
Do you do validation to make sure you are not setting up an open relay?
People can use your form to send stuff out?

It might be the destination to which you are sending is blocking your attempts.
IMHO, best to look at the mail log when using local MTA that then sends things out.
If you do not use a local MTA, but an SMTP session instead, you might be complicating matters dealing with extraneous characters that could cause problems.
Can the system in question if you use telnet remotemailserver 25 can you submit a test message from you to an address there?
One thing the ones that are working have in common is that they call the WYSIWYG editor to preview before sending
The issue here is the code because it is working in some cases, so it can't be the email function itself.

You will need to do before that line that is erroring out.

print_r($_POST)
die();
Ok, with those two lines, I got the output and all required fields were dumped correctly, but still not sending the email template
Do you check and validate the sender, recipient?

Do you log the requests so that you can see whether there is a pattern ?

Parsing errors ?
I will post the result, I just need to remove the personal data from my sample
Yes, the key here is just going to be going through every possible point of failure. Somewhere, something is not getting set or updated like it is in the others. 
This is the output
Array ( [section] => reservations [action] => reservation_request [Source_Code] => Company Code [request_email] => reservation-requests@domain.com [status] => In Process [code] => [form_type] => gatlinburg-town-square [Price] => 99.00 [First_Name] => Customer Data [Last_Name] => Customer Data [Spouse_Name] => Customer Data [Marital_Status] => Cohabiting [Husband_Occupation] => Table Games Supervisor/dealer [Wife_Occupation] => Table Games Supervisor/dealer [Address] => some address Dr [City] => Ocean Springs [State] => MS [Province] => [Zip_Code] => 11111 [Country] => United States [Day_Phone] => (222) 333-4444 [Night_Phone] => (222) 333-4444  [Email] => email-sample@email.com [Fax] => [Call_Time] => Evening [Arrival_Month] => January [Arrival_Date] => 15 [Arrival_Year] => 2022 [Checkin_Date] => Saturday, January 15, 2022 [Checkout_Date] => Tuesday, January 18, 2022 [Hotel] => Gatlinburg Town Square [Room_Type] => King Bed Guestroom [Nights] => 3 [Tickets] => [Guest] => 2 [Adults] => 2 [Juniors] => 0 [Children] => 0 [Income] => Over $100,000 [Age] => 07/10/1971 01/15/1987 [Card_Type] => MasterCard [Comments] => comments data here [check__fields] => status,#,First_Name,#,Last_Name,#,Spouse_Name,#,Marital_Status,#,Husband_Occupation,#,Wife_Occupation,#,Address,#,City,#,State,#,Zip_Code,#,Country,#,Day_Phone,#,Email,#Email,Arrival_Month,#,Arrival_Date,#,Arrival_Year,#,Hotel,#,Room_Type,#,Nights,#,Tickets,#,Guest,#,Adults,#,Juniors,#,Children,#,Income,#,Age,#,Card_Type,#,Card_Number,#,Card_Expiration,#,Card_Holder,# [id] => 21159 [update] => Send Request )

Open in new window

This is the information that is sent to the template
The error keeps coming back to this
[11-Jan-2022 18:36:02 UTC] PHP Warning:  mail() expects at least 3 parameters, 2 given in /home/customer/www/domain.com/public_html/reservations/admin/index.php on line 234

Open in new window

Which line is 234 here
/home/customer/www/domain.com/public_html/reservations/admin/index.php on line 234
And the error may not actually be that, but close to it. it may because you have a die()? in the print_r just to get the below output.

In the output below, go through each item like
section = reservations
action = reservation_request
.... and the rest that are needed.  Do these items match up with what is being expected?

Go through each one and check.

Array ( [section] => reservations [action] => reservation_request [Source_Code] => Company Code [request_email] => reservation-requests@domain.com [status] => In Process [code] => [form_type] => gatlinburg-town-square [Price] => 99.00 [First_Name] => Customer Data [Last_Name] => Customer Data [Spouse_Name] => Customer Data [Marital_Status] => Cohabiting [Husband_Occupation] => Table Games Supervisor/dealer [Wife_Occupation] => Table Games Supervisor/dealer [Address] => some address Dr [City] => Ocean Springs [State] => MS [Province] => [Zip_Code] => 11111 [Country] => United States [Day_Phone] => (222) 333-4444 [Night_Phone] => (222) 333-4444  [Email] => email-sample@email.com [Fax] => [Call_Time] => Evening [Arrival_Month] => January [Arrival_Date] => 15 [Arrival_Year] => 2022 [Checkin_Date] => Saturday, January 15, 2022 [Checkout_Date] => Tuesday, January 18, 2022 [Hotel] => Gatlinburg Town Square [Room_Type] => King Bed Guestroom [Nights] => 3 [Tickets] => [Guest] => 2 [Adults] => 2 [Juniors] => 0 [Children] => 0 [Income] => Over $100,000 [Age] => 07/10/1971 01/15/1987 [Card_Type] => MasterCard [Comments] => comments data here [check__fields] => status,#,First_Name,#,Last_Name,#,Spouse_Name,#,Marital_Status,#,Husband_Occupation,#,Wife_Occupation,#,Address,#,City,#,State,#,Zip_Code,#,Country,#,Day_Phone,#,Email,#Email,Arrival_Month,#,Arrival_Date,#,Arrival_Year,#,Hotel,#,Room_Type,#,Nights,#,Tickets,#,Guest,#,Adults,#,Juniors,#,Children,#,Income,#,Age,#,Card_Type,#,Card_Number,#,Card_Expiration,#,Card_Holder,# [id] => 21159 [update] => Send Request )

Open in new window


What are the required parameters? Sender, Recipient, body of the message?
Thank you, Scott, I checked and everything seems to be fine but now I'm testing my email address for proper structure and set up as far as authentication (Dmark). I will update this question once I get that sorted out
For the next handful of days, I will not be available very much. I know that some of the comments are pointing to an issue with the email server/providor but you are having success already, it is just something in this one area.

It could be a function that is not supported perhaps because you changed PHP versions. Or it could be a function that is relying on a setting in your php.ini that is not set here but was on the other server. Or it could be a variable that is not being properly passed.

Because you have tried so many options already, I would create a one page test php page and only use the function for this situation. Hard code variables first and run it through so you can eliminate the issue of variables being passed. If you are getting errors with hard coded data, that will help pinpoint.  Make sure to turn on errors for your test page so you can see the detail errors.

Thank you, Scott, I can say it is not DMARK as I added the record and the problem persist.
I will check the PHP.INI because that make could very well be the solution, and I will also try changing the PHP version to see what happens.
You get a parsing error that I've of three required parameters is missing.
Can you replicate the error by submitting sata missing the sender, missing the recipient, missing the message.

Alternatively, add to your handler a check to make sure sonething is set for these required parameters.

I would address the issue before the email send is attempted,
Record What parameters are received to see if I can explain why some fail.
You mentioned, "authentication (Dmark", which is not really how DMARC works, if that's what you mean.

Best to set DMARC p=none; sp=none; till all your delivery problems are resolved.
Thank you David
Hi Arnold and thank you for your input. You asked "What are the required parameters? Sender, Recipient, body of the message?"

in the output of what it is supposed to be sent as the sender, recipient, etc, you can see it is sent to the email template here:
From: domain.Com <reservations@domain.com> 
To: [request_email] 
Subject: Reservation request from [Source_Code] - [First_Name] [Last_Name]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
   <title>Reservation Status Update</title>
   <style type="text/css">
      #outlook a {padding:0;} 
      body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;}
      
      .ExternalClass {width:100%;} 
      .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} 
      #backgroundTable {margin:0; padding:0; width:100% !important; line-height: 100% !important;}

      img {outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;}
      a img {border:none;}
      .image_fix {display:block;}

      p {margin: 1em 0;}

      h1, h2, h3, h4, h5, h6 {color: black !important;}
      h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {color: blue !important;}
      h1 a:active, h2 a:active,  h3 a:active, h4 a:active, h5 a:active, h6 a:active {
         color: red !important; 
       }
      h1 a:visited, h2 a:visited,  h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited {
         color: purple !important; 
      }

      table td {border-collapse: collapse;}

      table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }

      a {color: blue;}

      @media only screen and (max-device-width: 480px) {

         a[href^="tel"], a[href^="sms"] {
                  text-decoration: none;
                  color: black; 
                  pointer-events: none;
                  cursor: default;
               }
         .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
                  text-decoration: default;
                  color: orange !important; 
                  pointer-events: auto;
                  cursor: default;
               }
      }
      
      @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {

         a[href^="tel"], a[href^="sms"] {
                  text-decoration: none;
                  color: blue;
                  pointer-events: none;
                  cursor: default;
               }
         .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
                  text-decoration: default;
                  color: orange !important;
                  pointer-events: auto;
                  cursor: default;
               }
      }
      @media only screen and (-webkit-min-device-pixel-ratio: 2) {
         
      }

      @media only screen and (-webkit-device-pixel-ratio:.75){
         
      }
      @media only screen and (-webkit-device-pixel-ratio:1){
         
      }
      @media only screen and (-webkit-device-pixel-ratio:1.5){
         
      }
      
   </style>

</head>
<body>

   <table  bgcolor="#FFFFFF"  cellpadding="10" cellspacing="0" border="0" align="center" id="backgroundTable">
     <tr>
      <td>
<table cellpadding="0" cellspacing="0" border="0" align="center" >
         
      
      
  
  <tr>
    
    <td>
      <table bgcolor="#FFFFFF" cellpadding="10" cellspacing="0" border="1">
      <tr>
        <td bgcolor="#FFE29E" colspan="2"><h4 style="text-align:center">New Reservation From [Source_Code]<br><br> 
         Office: 000-207-000 - Fax : 000-965-000 - After Hours / Weekends / Holidays: 000-000-000</h4>
        </td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Source Code: </b>[Source_Code]</td>
           <td width="400"  valign="top"><b>Best Time to Call:  </b>[Call_Time]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Package Price: </b>$[Price]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Check-In Date :  </b>[Checkin_Date]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>First Name: </b>[First_Name]</td>
           <td width="400"  valign="top"><b>Checkout-Date :  </b>[Checkout_Date]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Last Name: </b>[Last_Name]</td>
          <td width="400" bgcolor="#ebebeb" valign="top"><b>Hotel:  </b>[Hotel]</td>
        </tr>        
<tr>
           <td width="400"  valign="top"> <b>Spouse Name: </b>[Spouse_Name]</td>
           <td width="400"  valign="top"><b>Resort:  </b>[Resort]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Marital Status: </b>[Marital_Status]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Room Type:  </b>[Room_Type]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Husband's Occupation: </b>[Husband_Occupation]</td>
           <td width="400"  valign="top"><b>Nights:  </b>[Nights]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Wife's Occupation: </b>[Wife_Occupation]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Tickets:  </b>[Tickets]</td>
        </tr> 
<tr>
           <td width="400"  valign="top"> <b>Address: </b>[Address]</td>
           <td width="400"  valign="top"><b>Number of Guest:   </b>[Guest]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>City: </b>[City]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Adults (18+):  </b>[Adults]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>State: </b>[State]</td>
           <td width="400"  valign="top"><b>Juniors (12 - 17):  </b>[Juniors]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Province: </b>[Province]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Children (Under 12):  </b>[Children]</td>
        </tr> 
<tr>
           <td width="400"  valign="top"> <b>Zip Code: </b>[Zip_Code]</td>
           <td width="400"  valign="top"><b>Income:  </b>[Income]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Country: </b>[Country]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Age:  </b>[Age]</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Day Phone: </b>[Day_Phone]</td>
           <td width="400"  valign="top"><b>Card Type:  </b>[Card_Type]</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>Night Phone: </b>[Night_Phone]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Card Expiration:  </b>&nbsp;</td>
        </tr>
<tr>
           <td width="400"  valign="top"> <b>Email: </b>[Email]</td>
           <td width="400"  valign="top"><b>Name on card:  </b>&nbsp;</td>
        </tr>
<tr>
           <td width="400" bgcolor="#ebebeb" valign="top"> <b>FAX: </b>[Fax]</td>
           <td width="400" bgcolor="#ebebeb" valign="top"><b>Comments:  </b>[Comments]</td>
        </tr>
        <tr>
        <td colspan="2"><h4 style="text-align:center">domain.com<br><br>
domain.com</h4>
        </td>
        </tr>
        


        </table>
    </td>
  </tr>


      </table>
</td>
             
   </tr>
   </table>

</body>
</html>

Open in new window

This here is the output of dumping the data first as suggested by Scott and David when I hit "send request"
Array ( [section] => reservations [action] => reservation_request [Source_Code] => Company Code [request_email] => reservation-requests@domain.com [status] => In Process [code] => [form_type] => gatlinburg-town-square [Price] => 99.00 [First_Name] => Customer Data [Last_Name] => Customer Data [Spouse_Name] => Customer Data [Marital_Status] => Cohabiting [Husband_Occupation] => Table Games Supervisor/dealer [Wife_Occupation] => Table Games Supervisor/dealer [Address] => some address Dr [City] => Ocean Springs [State] => MS [Province] => [Zip_Code] => 11111 [Country] => United States [Day_Phone] => (222) 333-4444 [Night_Phone] => (222) 333-4444  [Email] => email-sample@email.com [Fax] => [Call_Time] => Evening [Arrival_Month] => January [Arrival_Date] => 15 [Arrival_Year] => 2022 [Checkin_Date] => Saturday, January 15, 2022 [Checkout_Date] => Tuesday, January 18, 2022 [Hotel] => Gatlinburg Town Square [Room_Type] => King Bed Guestroom [Nights] => 3 [Tickets] => [Guest] => 2 [Adults] => 2 [Juniors] => 0 [Children] => 0 [Income] => Over $100,000 [Age] => 07/10/1971 01/15/1987 [Card_Type] => MasterCard [Comments] => comments data here [check__fields] => status,#,First_Name,#,Last_Name,#,Spouse_Name,#,Marital_Status,#,Husband_Occupation,#,Wife_Occupation,#,Address,#,City,#,State,#,Zip_Code,#,Country,#,Day_Phone,#,Email,#Email,Arrival_Month,#,Arrival_Date,#,Arrival_Year,#,Hotel,#,Room_Type,#,Nights,#,Tickets,#,Guest,#,Adults,#,Juniors,#,Children,#,Income,#,Age,#,Card_Type,#,Card_Number,#,Card_Expiration,#,Card_Holder,# [id] => 21159 [update] => Send Request )

Open in new window

I'm still getting this error
[12-Jan-2022 16:47:14 UTC] PHP Warning:  mail() expects at least 3 parameters, 2 given in /home/customer/www/domain.com/public_html/reservations/admin/index.php on line 234


Open in new window

and the case within the script is
case "reservation_request":
                
                        
                        include_once(LEVEL."inc/emailer/emailer.php");
                        
                        if($_POST["form_type"] == "westgate-lakes"){
                                mail("westgate-lakes_reservation_request", $_POST);
                        }
                        
                        
                        elseif($_POST["form_type"] == "westgate-villas"){
                                mail("westgate-villas_reservation_request", $_POST);
                        }
                        
                        elseif($_POST["form_type"] == "westgate-town-center"){
                                mail("westgate-town-center_reservation_request", $_POST);
                        }
                        
                        
                        elseif($_POST["form_type"] == "westgate-palace"){
                                mail("westgate-palace_reservation_request", $_POST);
                        }
    
                        
                        elseif($_POST["form_type"] == "branson-woods"){
                                mail("branson-woods_reservation_request", $_POST);
                        }
                        
                        
                        elseif($_POST["form_type"] == "river-terrace"){
                                mail("river-terrace_reservation_request", $_POST);
                        }
                        
                        
                        elseif($_POST["form_type"] == "westgate-myrtle-beach"){
                                mail("westgate-myrtle-beach_reservation_request", $_POST);
                        }
                        
                        
                        elseif($_POST["form_type"] == "westgate-smoky-mountain"){
                                mail("westgate-smoky-mountain_reservation_request", $_POST);
                        }
                        
                        
                        elseif($_POST["form_type"] == "westgate-las-vegas"){
                                mail("westgate-las-vegas_reservation_request", $_POST);
                        }
                        
                        
                        elseif($_POST["form_type"] == "westgate-williamsburg"){
                                mail("westgate-williamsburg_reservation_request", $_POST);
                        }

                                                
                
                        elseif($_POST["form_type"] == "roberts-grove-beach"){
                                mail("roberts-grove-beach_reservation_request", $_POST);
                        }
                        
                        
                        else {
                                mail("reservation_request",$_POST);
                                
                        }

Open in new window

of which the line generating the error at the end is
else {
                                mail("reservation_request",$_POST);
                                
                        }

Open in new window

and the other part in the script that relates to that case is
case "reservation_request":
                        $record = $reservation->getRecord();
                        $res = $reservation->showRecord($record,$reservation->lists);
                        $res = array_merge(array(
                            array( "name" => "Source_Code",
                            "title" => "Source Code",
                            "value" => $reservation->lists["Source_Code"]),
                            array( "name" => "request_email",
                            "type" => "hidden",
                            "value" => $reservation->lists["request_email"])
                            ),$res);
                        $res = unsetFields($res,'Card_Number,Card_Expiration,Card_Holder,I_Agree,html');
                        $smarty->assign("reservation", $res);
                break;

Open in new window

every other case for sending emails in this script is working perfectly except this one

Please help as this is a production website and this is the only thing not working, but it is very important
I'm wondering if the two parameters in the error
PHP Warning:  mail() expects at least 3 parameters, 2 given

Open in new window

are these here
$res = array_merge(array(
                            array( "name" => "Source_Code",
                            "title" => "Source Code",
                            "value" => $reservation->lists["Source_Code"]),
                            array( "name" => "request_email",
                            "type" => "hidden",
                            "value" => $reservation->lists["request_email"])
                            ),$res);

Open in new window

and the 3rd one missing is the "From" that is in the email Template? Could that be it?
These are the values in the template
From: domain.Com <reservations@domain.com> 
To: [request_email] 
Subject: Reservation request from [Source_Code] - [First_Name] [Last_Name]

Open in new window

So "To" and "Subject" are directly in the script but not "From" is that it? and if so, just to test, how could I add the value "From" directly in the script?
Check whether the issue is the absence of the requesting email addres. when it is missing, the message handler kicks it out.

Try adding a check, if the requesting email is not provided default it to a catch all, so that you can see whether this change resolves the parsing error.

the other possibility is that the email being provided for the requestor in someway might be malformed, or includes more info than you expect.

The info you provide is the message body and depending on your setup, might not be relevant/applicable.

Is your mail() setup goes through the local MTA? Or is the Mail handler setup is to perform an SMTP session where the script identifies which mail server is responsible for the recipient and initiates a connection to that server.
I went back to the beginning (original file) and this is the error if first saw
Error: 550 Missing internal data in the header. Message discarded.

Open in new window

However, I tested the rest of email() cases and they work perfectly 
Without know what the specific error means as to the data you are rendering, it is merely a guess from me.

The error is from the exchange, or some validation?
I have not seen this type of message originating from a server interaction,

Sender, recipient is identified in the session.

I do not know whether what you are using requires that certain things be present before the email handler is invoked. in some circumstance one of three parameters is missing, in this one it says something is missing from the header, but not what.
Is it missing the sender, or it is missing the header portion of the message body:
To:
From
Subject:
Date: (often is added by the mailserver if missing)

message body viewed by the recipient. (not sure you will get an error if you send a messaeg without body content.


What I did see is this error related to an old wordpress post. is this what you are using, wordpress?

https://wordpress.org/support/topic/mails-not-sending-missing-internal-data-in-the-header-message-discarded/
No, I use Joomla, but what I think may work is to change the way the email is sent and make it similar to the ones that are working. This one is working
case "change_status":
                        $data = fetchArray($_POST,"status");
                        $reservation->edit($data,$_REQUEST["id"]);
                        $res = $reservation->getByID($_REQUEST["id"]);
                        include_once(LEVEL."inc/emailer/emailer.php");
                        SendEmail("change_status",$res, false);
                        require_once ($spaw_root .'spaw_control.class.php');
                        $spaw = new SPAW_Wysiwyg('content', $body,'en',
                        'default', 'default', '100%', '500px', '','');
                        $smarty->assign('spaw', $spaw->getHTML());
                        $smarty->assign("email", $email);

Open in new window

and this one is the one that is not working
case "reservation_request":
                        $record = $reservation->getRecord();
                        $res = $reservation->showRecord($record,$reservation->lists);
                        $res = array_merge(array(
                            array( "name" => "Source_Code",
                            "title" => "Source Code",
                            "value" => $reservation->lists["Source_Code"]),
                            array( "name" => "request_email",
                            "type" => "hidden",
                            "value" => $reservation->lists["request_email"])
                            ),$res);
                        $res = unsetFields($res,'Card_Number,Card_Expiration,Card_Holder,I_Agree,html');
                        $smarty->assign("reservation", $res);

Open in new window

and they are both in the same script, I was wondering if anyone can help me modify the one that it is not working 
The issue is what is missing when the person is making a reservation request?

in the situation such as yours, personally, I would try to make a reservation in an effort to identify when this error occurs. It is impractical to locate the user and ask them what they submitted as their effort failed.
 
filling out all the fields, noting what is where and see what happens
And then varing what is omitted to see if it can match the error you saw.
If you match, you have a basis on what needs to be added, possibly adding a check to require a field before a user can submit the form.....
No, this is after the person submits the request. All the values needed are now in the database, and the email I'm working on is sent to the hotel requesting a reservation. This has worked for many years, even on my previous server with the same PHP version, but something changed from server to server.
I went from Redhat 7.9 to Ubuntu
check whether the external firewall rules for the old server (iP) are different that the firewall rules that apply to the new IP.

You keep posting what seems to be PHP errors versus what is going on in the email handler, MTA.


Does the local MTA reject the message when the 500 error occurs?
Unfortunately, with this new Cloud hosting I have no access to MTA logs
Tip: If you use a Mail Relay like MailGun, then you have access to all your MTA logs inside of MailGun.
Please disregard this question. Thank you Ddavis, Scott, and Arnold for your input, but I have decided not to use this new server configuration so I won't be needed any more troubleshooting on this issue.

Please delete this question if possible.

Thanks again,
Jorge B.
ASKER CERTIFIED SOLUTION
Avatar of Jorge Batres
Jorge Batres
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial