diff options
author | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-08-06 00:37:00 +0100 |
---|---|---|
committer | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-08-06 00:37:00 +0100 |
commit | ee02363d07131379c1e2537cffa20c453f596cad (patch) | |
tree | 4f770efa72aee4a7daa9f1b80f8c8a4ba7a43c8a /daemon.php | |
parent | Fix simultaneous build detection, fix sorting on keyboard layouts (diff) | |
download | gentoaster-ee02363d07131379c1e2537cffa20c453f596cad.tar.gz gentoaster-ee02363d07131379c1e2537cffa20c453f596cad.tar.bz2 gentoaster-ee02363d07131379c1e2537cffa20c453f596cad.zip |
Add email notification support
Diffstat (limited to 'daemon.php')
-rw-r--r-- | daemon.php | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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)); |