From: Vincent Zanotti Date: Wed, 30 Apr 2008 13:31:09 +0000 (+0200) Subject: Adds an helper for newsletter's bounces processing -- analyzes email from its standar... X-Git-Tag: core/1.0.0~221 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=06bdd610fc586bb4dd3f306e0bb6365fcf001f31;p=platal.git Adds an helper for newsletter's bounces processing -- analyzes email from its standard input, and checks that the email is in the database (otherwise prompting the root to look for the real email address in the bounce's headers). Signed-off-by: Vincent Zanotti --- diff --git a/bin/emails.broken.helper.php b/bin/emails.broken.helper.php new file mode 100755 index 0000000..c88db0b --- /dev/null +++ b/bin/emails.broken.helper.php @@ -0,0 +1,67 @@ +#!/usr/bin/php5 -q +\n"); + exit(1); +} else { + $output = $opts['o']; +} + +$input_fd = fopen("php://stdin", "r"); +$output_fd = fopen($output, "a"); + +while ($_email = fgets($input_fd)) { + $_email = trim($_email); + $email = valide_email($_email); + if (empty($email) || $email=='@') { + printf(">> %s: invalid email\n", $_email); + continue; + } + + $sel = XDB::query( + "SELECT e1.uid, e1.panne != 0 AS panne, count(e2.uid) AS nb_mails, u.nom, u.prenom, u.promo, a.alias + FROM emails AS e1 + LEFT JOIN emails AS e2 ON (e1.uid = e2.uid AND FIND_IN_SET('active', e2.flags) AND e1.email != e2.email) + INNER JOIN auth_user_md5 AS u ON (e1.uid = u.user_id) + INNER JOIN aliases AS a ON (u.user_id = a.id AND FIND_IN_SET('bestalias',a.flags)) + WHERE e1.email = {?} + GROUP BY e1.uid", $email); + if ($sel->numRows() > 0) { + fwrite($output_fd, $email . "\n"); + } else { + printf(">> %s: email not in the database\n", $_email); + } +} + +fclose($input_fd); +fclose($output_fd); + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?>