I am building up an application using AngularJS and PHPMailer. I need to pass an array from my Angular application to PHPMailer and then retrieve the array in PHPMailer and mail the data to the client.
$scope.data = {};
var link = 'http://uvw.com/mail.php';
          $http.post(link, {order:$scope.listItems}).then(function (res){
                    $scope.response = res.data;
                    console.log($scope.response);
          });
Here, $scope.listItems is an array which consists of head fields like customer name, customer email, customer phone etc and lots of data under each head. So it boils down to like $scope.listItems.customerName, $scope.listItems.customerPhone etc. I retrieve the data in Angular very easily using angular forEach.
i have been successful in passing the data to PHPMailer, but i have got no idea of how to retrieve the data in PHPMailer and mail it forward.
UPDATE
PHPMailer Code
    if (isset($_SERVER['HTTP_ORIGIN'])) {
        header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Max-Age: 86400');    
    }
    if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
        if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
            header("Access-Control-Allow-Methods: GET, POST, OPTIONS");         
        if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
            header("Access-Control-Allow-Headers:        
            {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
        exit(0);
    }
    $postdata = file_get_contents("php://input");
    if (isset($postdata)) {
        $request = json_decode($postdata);
        foreach ($order as $value) {
            $body=$order;
        }
        require("PHPMailer/class.phpmailer.php");
        $mail = new PHPMailer();
        $mail->IsSMTP();               
        $mail->Host = "localhost"; 
        $mail->SMTPAuth = true; 
        $mail->Username = "support@uvw.com"; 
        $mail->Password = "support@123";
        $mail->From = "support@uvw.com";
        $mail->FromName = "uvw";
        $mail->AddAddress("orders@uvw.com", "Orders");
        $mail->WordWrap = 50;
        $mail->IsHTML(true);                         
        $mail->Subject = "New Customer";
        $mail->Body    = $body;
        $mail->AltBody = "Alternate Body";
        if(!$mail->Send())
        {
            echo "Message could not be sent. <p>";
            echo "Mailer Error: " . $mail->ErrorInfo;
            exit;
        }
        echo "Message has been sent";
    }
    else {
        echo "Could not Mail";
    }
$scope.listItems datastructue
$scope.listItems.customerName,
$scope.listItems.customerEmail,
$scope.listItems.customerPhone,
$scope.listItems.customerAddress
 
     
     
    