aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'daemon.php')
-rw-r--r--daemon.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/daemon.php b/daemon.php
index 65d7d2b..4041317 100644
--- a/daemon.php
+++ b/daemon.php
@@ -4,6 +4,7 @@
// Licensed under GPL v3, see COPYING file
require_once "config.php";
+ require_once "Mail.php";
$worker = new GearmanWorker();
$worker->addServer();
@@ -36,6 +37,33 @@
$stmt->bind_param("sds", $result, $returncode, $handle);
$stmt->execute();
$stmt->close();
+
+ $query = "SELECT id, email FROM builds WHERE handle = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $handle);
+ $stmt->execute();
+ $stmt->bind_result($buildID, $email);
+ $stmt->fetch();
+
+ if($email != null) {
+ $headers = array('From' => SMTP_EMAIL,
+ 'To' => $email,
+ 'Subject' => "Your Gentoaster build has completed");
+
+ $smtp = Mail::factory('smtp',
+ array ('host' => SMTP_HOST,
+ 'auth' => true,
+ 'username' => SMTP_USERNAME,
+ 'password' => SMTP_PASSWORD));
+
+ $body = "Your Gentoaster build has finished.\n\n"
+ ."You can view the results at ".GENTOASTER_URL
+ ."/status.php?uuid=".$buildID;
+
+ $mail = $smtp->send($email, $headers, $body);
+ }
+
+ $stmt->close();
$db->close();
return serialize(array($returncode, $result));