Path Validation (Directory Traversal): Added a strict check for the --log-dir argument. The script now only accepts /var/log or /var/log/mail to prevent it from processing malicious files if a user tries to pass an arbitrary path.
Secure Temp Files: Replaced the hardcoded /tmp/ directory with the environment-aware ${TMPDIR:-/tmp}/ everywhere mktemp is used, so the script respects the host operating system's settings.
LOCK File Security: Appended the user identifier (${UID}) to the LOCK file name (e.g., postfix_summary_${UID}.lock). This prevents a scenario where one user locks out execution for all other users on the system.