<?php

$to = "livia.mcconaty@partnersgroup.com";
// $to = "kurtis@jutecreative.com";
$files = ["mockup-2"];
// $files = ["us-version-A"];
$folder = "email-2";

foreach ($files as $file) {
    $content = file_get_contents(__DIR__."/$folder/$file.html");
    if (!$content) {
        echo PHP_EOL."Not a real file: $file".PHP_EOL;
        continue;
    }
    $content = str_replace("\n", "", $content);
    $payload = [
        "to" => $to,
        "subject" => "Email Preview: $file",
        "message" => $content,
        "secret" => "YyyYyHgy765765757yyyyYYYy0Wm08p4bT(qwyRGq",
    ];

    $url = "https://sendmail.ofco.cloud/send-email";
    $c = curl_init($url);
    curl_setopt($c, CURLOPT_HEADER, false);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($c, CURLOPT_HTTPHEADER, ["Content-type: application/json"]);
    curl_setopt($c, CURLOPT_POST, true);
    curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($payload));

    $json_response = curl_exec($c);
    curl_close($c);

    $res = json_decode($json_response);
    var_dump($res);
}
