Initial commit
This commit is contained in:
commit
78a4e70036
24 changed files with 1067 additions and 0 deletions
53
res/php/sendmail.php
Executable file
53
res/php/sendmail.php
Executable file
|
@ -0,0 +1,53 @@
|
|||
<?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;
|
||||
}
|
Reference in a new issue