[web-master] main: Add endpoint for fetching all the email aliases for the SMTP server
| From: | Derick Rethans | Date: | Tue, 20 Jan 2026 16:27:50 +0000 |
| Subject: | [web-master] main: Add endpoint for fetching all the email aliases for the SMTP server | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-33531@lists.php.net to get a copy of this message | ||
Author: Derick Rethans (derickr)
Date: 2026-01-20T16:27:40Z
Commit: https://github.com/php/web-master/commit/30deedb750707f573f4fab7972723b2e913e6977
Raw diff: https://github.com/php/web-master/commit/30deedb750707f573f4fab7972723b2e913e6977.diff
Add endpoint for fetching all the email aliases for the SMTP server
Changed paths:
A public/fetch/email-aliases.php
Diff:
diff --git a/public/fetch/email-aliases.php b/public/fetch/email-aliases.php
new file mode 100644
index 0000000..74cf3bb
--- /dev/null
+++ b/public/fetch/email-aliases.php
@@ -0,0 +1,45 @@
+<?php
+
+use App\DB;
+
+require __DIR__ . '/../../vendor/autoload.php';
+
+function error($text, $status)
+{
+ switch((int)$status) {
+ default:
+ case 500:
+ header("HTTP/1.0 500 Internal server error");
+ break;
+
+ case 404:
+ header("HTTP/1.0 404 Not Found");
+ break;
+
+ case 401:
+ header("HTTP/1.0 401 Unauthorized");
+ break;
+ }
+ exit;
+}
+
+// original token defined in ansible vault and in fetch-aliases-from-main.sh script on
php-smtp4:~/emailsync
+(!isset($_GET['token']) || sha1($_GET['token']) !=
"1789734af16d0fe009375e1f4dbe11e02c5919bc") && error("token not
correct.", 401);
+
+$pdo = DB::connect();
+
+$stmt = $pdo->prepare("SELECT username, email FROM users WHERE enable = 1 AND email !=
'' ORDER BY username");
+if (!$stmt->execute()) {
+ error("This error should never happen", 500);
+}
+
+$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
+if (!$results) {
+ error("This should never happen either", 404);
+}
+
+echo "username\temail\n";
+
+foreach ($results as $result) {
+ echo $result['username'], "\t", $result['email'], "\n";
+}