54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
|
<?php
|
||
|
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
|
||
|
# MIT License
|
||
|
|
||
|
$ini = pParse_ini_file("../../filespread.ini");
|
||
|
|
||
|
date_default_timezone_set($ini["timezone"]);
|
||
|
|
||
|
require '../../vendor/autoload.php';
|
||
|
|
||
|
$list = "../../lists/" . $_GET["list"];
|
||
|
$template = "../../templates/" . $_GET["template"];
|
||
|
|
||
|
$addresses = file($list);
|
||
|
$content = file($template);
|
||
|
|
||
|
$email = new PHPMailer;
|
||
|
|
||
|
$email->setFrom($ini["email"], $ini["name"]);
|
||
|
$email->Subject = parseSubject($content);
|
||
|
$email->Body = parseText($content);
|
||
|
|
||
|
foreach ($addresses as $address) {
|
||
|
$email->AddAddress($address);
|
||
|
}
|
||
|
|
||
|
$file_to_attach = '../../assets/file.bin';
|
||
|
$filename = parseFilename($content);
|
||
|
|
||
|
$email->AddAttachment($file_to_attach, $filename);
|
||
|
|
||
|
if (!$email->Send()) {
|
||
|
echo "-1";
|
||
|
echo $email->ErrorInfo;
|
||
|
} else {
|
||
|
echo "0";
|
||
|
}
|
||
|
|
||
|
function parseSubject($content) {
|
||
|
return substr($content[0], 7);
|
||
|
}
|
||
|
|
||
|
function parseFilename($content) {
|
||
|
return substr($content[1], 10);
|
||
|
}
|
||
|
|
||
|
function parseText($content) {
|
||
|
$text = substr($content[2], 6);
|
||
|
for ($i = 3; $i < count($content); $i++) {
|
||
|
$text = $text . $content[$i];
|
||
|
}
|
||
|
return $text;
|
||
|
}
|