Created
February 9, 2025 09:10
-
-
Save z-image/4e29da1f01e040da80f2edd1c7e63b4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function vdelivermail(..., env_vars): | |
// get_arguments(): Parse EXT, split at *first* hyphen | |
EXT = env_vars["EXT"] // e.g., "no-reply-office-sofia@domain.com" | |
TheUser = EXT | |
TheUserExt, TheExt = split_at_first_hyphen(EXT) // "no", "reply-office-sofia" | |
replace_all(TheExt, ".", ":") | |
// Main Logic: Lookup user (full name first, then base name) | |
if not vauth_getpw(TheUser, ...): // Try full username "no-reply-office-sofia" | |
if QMAIL_EXT and TheUser != TheUserExt: | |
if not vauth_getpw(TheUserExt, ...): // Try base username "no" | |
usernotfound() | |
exit | |
else: | |
usernotfound() | |
exit | |
checkuser() | |
exit() | |
function checkuser(): | |
//... | |
check_forward_deliver(vpw.pw_dir) | |
//... | |
function check_forward_deliver(dir): | |
// check_forward_deliver(): Recursive .qmail lookup | |
change_dir(dir) | |
if TheExt: // Extension exists? | |
if exists(".qmail-" + TheExt): // Try full extension ".qmail-reply-office-sofia" | |
process(".qmail-" + TheExt) | |
return 1 | |
for i = length(TheExt) - 1 downto 0: // Loop backwards | |
if i == 0 or TheExt[i-1] == '-': // Hyphen or start? | |
prefix = substring(TheExt, 0, i - 1) | |
if exists(".qmail-" + prefix + "-default"): | |
process(".qmail-" + prefix + "-default") | |
return 1 | |
if exists(".qmail"): // Try standard .qmail | |
process(".qmail") | |
return 1 | |
return -1 // No .qmail file | |
// Helper functions (simplified names) | |
function split_at_first_hyphen(str): | |
// Returns (prefix, suffix) split at first '-', or (str, "") if no '-' | |
index = find_first(str, '-') | |
if index != -1: | |
return (substring(str, 0, index - 1), substring(str, index + 1)) | |
return (str, "") |
Author
z-image
commented
Feb 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment