2016-04-06 17:30:05 +02:00
|
|
|
<?php
|
|
|
|
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
|
|
|
|
# MIT License
|
|
|
|
|
2016-11-12 17:46:40 +01:00
|
|
|
$ini = parse_ini_file("../../filespread.ini");
|
2016-04-06 17:30:05 +02:00
|
|
|
|
|
|
|
date_default_timezone_set($ini["timezone"]);
|
|
|
|
|
|
|
|
require '../../vendor/autoload.php';
|
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
function main($ini) {
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
$data = json_decode($_GET["data"], true);
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
$list = "../../lists/" . $data["list"];
|
|
|
|
$addresses = file($list);
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
$content = $data["body"];
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
$title = $data["title"];
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
$filename = $data["filename"];
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
foreach ($addresses as $address) {
|
|
|
|
if (sendMail($title, $content, $filename, $address, $ini) != 0) {
|
|
|
|
print "-1";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
print "0";
|
2016-04-06 17:30:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
function sendMail($title, $content, $filename, $address, $ini) {
|
|
|
|
|
|
|
|
$mail = new PHPMailer;
|
2016-04-06 17:30:05 +02:00
|
|
|
|
2016-11-20 08:47:12 +01:00
|
|
|
$mail->setFrom($ini["email"], $ini["name"]);
|
|
|
|
$mail->Subject = $title;
|
|
|
|
$mail->Body = $content;
|
|
|
|
|
|
|
|
$mail->addAddress($address);
|
|
|
|
|
|
|
|
if (isset($ini["reply"])) {
|
|
|
|
$mail->addReplyTo($ini["reply"]);
|
2016-04-06 17:30:05 +02:00
|
|
|
}
|
2016-11-20 08:47:12 +01:00
|
|
|
|
|
|
|
$mail->AddAttachment("../../assets/file.bin", $filename);
|
|
|
|
|
|
|
|
if (!$mail->Send()) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-06 17:30:05 +02:00
|
|
|
}
|
2016-11-20 08:47:12 +01:00
|
|
|
|
|
|
|
main($ini);
|