UPD: changed to base64 mime type

This commit is contained in:
xpk 2021-04-30 11:51:41 +08:00
parent c2eb9b55ba
commit 5f84ba1b4d
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86

28
php/mailapi.php Normal file
View File

@ -0,0 +1,28 @@
<?php
if (empty($_POST)) {
echo 'Usage: curl -d "subject=email subject&sender=SENDER@DOMAIN.TLD&recipient=RECIPIENT@DOMAIN.TLD&message=$(base64 /tmp/mailbody.txt)" -X POST https://racker.pro/mailapi/';
exit();
} else {
include('Mail.php');
$to = $_POST['recipient'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/plain; charset=ISO-8859-1';
$headers[] = 'Content-Transfer-Encoding: base64';
$headers[] = 'X-Mailer: PHP/' . phpversion();
//$headers[] = 'To: ' . $_POST['recipient'];
$headers[] = 'From: ' . $_POST['sender'];
if (mail($to, $subject, $message, implode("\r\n", $headers))) {
echo 'Your message has been sent.';
} else {
echo 'There was a problem sending the email.';
}
}
?>