Example #1
0
        if ($dbh->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
            // XXX PDO lastInsertId() doesnt work for PostgreSQL
            $q2 = $dbh->prepare('SELECT id FROM release_rcpt WHERE release_id = :id AND queueid = :queueid AND token = :token;');
            $q2->execute([':id' => $row['id'], ':queueid' => $mail->id, ':token' => $token]);
            $row2 = $q2->fetch(PDO::FETCH_ASSOC);
            $insertid = $row2['id'];
        }
        mail($mail->msgto, 'Release blocked email', "Hi,\r\n\r\nThe spam filter blocked an email from {$mail->msgfrom}, but the sender has insisted that the email is genuine. To view or release the email, please click this link: https://release.example.com/?id={$insertid}&token={$token}\r\n\r\nThe Example.com support team\r\nhttp://example.com\r\n\r\nThis email message was auto-generated.", $mail_headers);
    }
}
$q = $dbh->prepare('SELECT * FROM release_sender AS r INNER JOIN release_rcpt AS rr ON r.id = rr.release_id WHERE status = 1;');
$q->execute();
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
    $host = $soap_hosts[$row['node']];
    $id = $row['queueid'];
    echo "Release {$id} from {$host}\n";
    try {
        $client = new SoapClient('https://' . $host . '/remote/?wsdl', ['features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'location' => 'https://' . $host . '/remote/', 'uri' => 'urn:halon', 'login' => $soap_user, 'password' => $soap_pass]);
        $ret = $client->mailQueueRetry(['id' => $id]);
    } catch (Exception $e) {
        if ($e->getMessage() == 'queueid not found') {
            $q2 = $dbh->prepare('UPDATE release_rcpt SET status = -1 WHERE id = :id;');
            $q2->execute([':id' => $row['id']]);
        } else {
            echo $e->getMessage();
            continue;
        }
    }
    $q2 = $dbh->prepare('UPDATE release_rcpt SET status = 2 WHERE id = :id;');
    $q2->execute([':id' => $row['id']]);
}