Files
resatennis_tyroltenn/IDrive/.config/sendmail.php

63 lines
1.8 KiB
PHP
Executable File

<?php
$username = $argv[1];
include_once 'path.php';
$successBackup = "Successful Backup";
$successRestore = "Successful Restore";
$jobType = $argv[2];
$job = $jobType . $argv[3];
$status = $argv[4];
$content = $argv[5];
# Add app version to the mail
$content .= "\n" . $appVersion."\nRelease Date: ".$releaseDate;
# get machine based content
machineBasedContent($machine);
if($argc != 6) {
$msg = "Argument mismatch.";
}
$jobs = array();
$jobs = Scheduler::ReadJobs("cmd", $username);
$host = Scheduler::GetHost($username);
$job_type = isset($jobs[$job]["job_type"]) ? strtolower($jobs[$job]["job_type"]) : "";
$scheduler = isset($jobs[$job]["scheduler"]) ? $jobs[$job]["scheduler"] : "";
if(isset($scheduler) && isset($scheduler["email_notify"]) && $scheduler["email_notify"] == "on") {
if(isset($scheduler["notify_option"])) {
if($scheduler["notify_option"] == "notify_failure" && ($status == $successBackup || $status == $successRestore)) {
$msg = "Notify only in failure.";
echo $msg;exit;
}
} else {
$msg = "Not subscribed for notification.";
echo $msg;exit;
}
} else {
$msg = "Not subscribed for notification.";
echo $msg;exit;
}
$sendto = urlencode(str_replace(";", ",", $scheduler["email"]));
$subject = urlencode(ucfirst($job_type)." Status Report [$username][$status]");
$userName = $username;
readAccountSettingsFile();
$username = urlencode($username);
$password = urlencode(base64_decode($_SESSION['password']));
$content = urlencode($content); # Encoding the email content
$postFields = "username=$username&password=$password&to_email=$sendto&subject=$subject&content=$content";
$ret = getCurlOutput(getHash("06"), $postFields);
$msg = "Email Notification sent to {$sendto}\n";
if($ret['status'] == false) {
Scheduler::Log("Send Mail Error: {$ret['output']}, Curl error: {$ret['error']}");
}
echo $msg;