Files
wevads-platform/scripts/api_header-builder.php
2026-02-26 04:53:11 +01:00

28 lines
1.0 KiB
PHP
Executable File

<?php
header('Content-Type: application/json');
$action = $_POST['action'] ?? $_GET['action'] ?? '';
switch ($action) {
case 'encode':
$text = $_POST['text'] ?? $_GET['text'] ?? '';
echo json_encode(['original' => $text, 'base64' => '=?UTF-8?B?' . base64_encode($text) . '?=']);
break;
case 'build':
$from = $_POST['from_name'] ?? 'Sender';
$email = $_POST['from_email'] ?? 'sender@example.com';
$subject = $_POST['subject'] ?? 'No Subject';
$headers = [
"From: =?UTF-8?B?" . base64_encode($from) . "?= <$email>",
"Subject: =?UTF-8?B?" . base64_encode($subject) . "?=",
"MIME-Version: 1.0",
"Content-Type: text/html; charset=UTF-8",
"Message-ID: <" . uniqid() . "@" . explode('@', $email)[1] . ">",
"Date: " . date('r')
];
echo json_encode(['headers' => $headers, 'raw' => implode("\r\n", $headers)]);
break;
default:
echo json_encode(['actions' => ['encode','build']]);
}