a3c02b057d
Res T123,T124
59 lines
1.1 KiB
PHP
Executable file
59 lines
1.1 KiB
PHP
Executable file
<?php
|
|
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
|
|
# MIT License
|
|
|
|
$ini = parse_ini_file("../../filespread.ini");
|
|
|
|
date_default_timezone_set($ini["timezone"]);
|
|
|
|
require '../../vendor/autoload.php';
|
|
|
|
function main($ini) {
|
|
|
|
$data = json_decode($_GET["data"], true);
|
|
|
|
$list = "../../lists/" . $data["list"];
|
|
$addresses = file($list);
|
|
|
|
$content = $data["body"];
|
|
|
|
$title = $data["title"];
|
|
|
|
$filename = $data["filename"];
|
|
|
|
foreach ($addresses as $address) {
|
|
if (sendMail($title, $content, $filename, $address, $ini) != 0) {
|
|
print "-1";
|
|
exit;
|
|
}
|
|
}
|
|
|
|
print "0";
|
|
|
|
}
|
|
|
|
function sendMail($title, $content, $filename, $address, $ini) {
|
|
|
|
$mail = new PHPMailer;
|
|
|
|
$mail->setFrom($ini["email"], $ini["name"]);
|
|
$mail->Subject = $title;
|
|
$mail->Body = $content;
|
|
|
|
$mail->addAddress($address);
|
|
|
|
if (isset($ini["reply"])) {
|
|
$mail->addReplyTo($ini["reply"]);
|
|
}
|
|
|
|
$mail->AddAttachment("../../assets/file.bin", $filename);
|
|
|
|
if (!$mail->Send()) {
|
|
return -1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
main($ini);
|