From 14d499350e83a9da5ac20ef2acc2c6806c932fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Zolt=C3=A1n?= Date: Sat, 2 May 2026 23:46:29 +0200 Subject: [PATCH] Improvements (cronmail) and fixes in mail utilities. --- .metadata | Bin 22712 -> 22705 bytes .utils/mail/README.md | 10 ++++-- .utils/mail/cronmail | 52 ++++++++++++++++++++++++++++ .utils/mail/mail.dummy | 3 -- .utils/mail/{mail.s-nail => s-nail} | 12 +++---- 5 files changed, 65 insertions(+), 12 deletions(-) create mode 100755 .utils/mail/cronmail delete mode 100644 .utils/mail/mail.dummy rename .utils/mail/{mail.s-nail => s-nail} (77%) mode change 100644 => 100755 diff --git a/.metadata b/.metadata index 25b1fd180789716d5228b27192715a54269c1d8a..97998198c7b56adf9453a5be65db17705c44d10c 100644 GIT binary patch delta 211 zcmdn7k#XZj#tq9jcw92RWikN4|3@`klQ)`KZGOXXon`Vl7LLgWIQch=@fC>j@aI94 zOjn$tHMx;hbn*pz!O1(64;hx0Wabp>=O$+6=qDHD=Ybdu*;V;DnNU(U8ln+oJ_x*> ztnVhbd4h_rfIgDeV%~1Hf|F~M4{a`2aTb`| y$ErAa0~_yVdDE@jJRl_?OF>}s1BZ*^lk==OCm%3j +# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) +# 2026-05-02 v0.1 Initila release. + +# Initialisations. +# +SUBJECT="" +RECIPIENT="$USER" # Default recipient. +MESSAGE="" +MUA="/usr/local/bin/mail" # Custom mail user agent script. + +# Parsing the stdin line by line. +# +while IFS= read -r line +do + # Parses the recipient. + if [[ "$line" =~ ^(T|t)o:\ .*$ ]]; then + RECIPIENT="${line#*: }" + # Parses the subject line. + elif [[ "$line" =~ ^(S|s)ubject:\ .*$ ]]; then + SUBJECT="${line#*: }" + # Message body starts with an empty line. + elif [[ "$line" =~ ^$ ]]; then + MESSAGE+="\n" + # Collects the message body lines. + # The first empty line will be stripped. + elif [ -n "$MESSAGE" ]; then + [[ "$MESSAGE" = "\n" ]] \ + && MESSAGE="$line\n" \ + || MESSAGE+="$line\n" + fi +done + +# Calls the mail user agent. +# +if [ -x "$MUA" ]; then + if [ -n "$SUBJECT" -o -n "$MESSAGE" ]; then + echo -e "$MESSAGE" | "$MUA" -s "$SUBJECT" "$RECIPIENT" + fi +fi + +# That's all, Folks! :) diff --git a/.utils/mail/mail.dummy b/.utils/mail/mail.dummy deleted file mode 100644 index 9985fd4..0000000 --- a/.utils/mail/mail.dummy +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# -# Dummy file to met the dependencies. Does nothing. diff --git a/.utils/mail/mail.s-nail b/.utils/mail/s-nail old mode 100644 new mode 100755 similarity index 77% rename from .utils/mail/mail.s-nail rename to .utils/mail/s-nail index 58c4dd6..ccc4857 --- a/.utils/mail/mail.s-nail +++ b/.utils/mail/s-nail @@ -20,7 +20,7 @@ SMTP_PASS="topsecret" # s-nail call. # -if [ -x "$(which s-nail 2>/dev/null)" ]; then +if [ -x "/bin/s-nail" ]; then # The recipient's address is the last argument. recipient="${@: -1}" set -- "${@: 1: $#-1}" @@ -29,10 +29,10 @@ if [ -x "$(which s-nail 2>/dev/null)" ]; then [[ "$recipient" = "$USER" ]] && recipient="$TO" [[ "$recipient" = "$USER@$HOSTNAME" ]] && recipient="$TO" if [ -n "$recipient" ]; then - "$(which s-nail)" -S from="$FROM" -S v15-compat \ - -S smtp-auth="login" -S smtp-use-starttls \ - -S mta="$SMTP_PROTO://$SMTP_USER:$SMTP_PASS@$SMTP_SERVER" \ - -S record="/var/mail/$USER" \ - "${@}" $recipient + "/bin/s-nail" -S from="$FROM" -S v15-compat \ + -S smtp-auth="login" $([[ "$SMTP_PROTO" = "submission" ]] && echo "-S smtp-use-starttls") \ + -S mta="$SMTP_PROTO://$SMTP_USER:$SMTP_PASS@$SMTP_SERVER" \ + -S record="/var/mail/$USER" \ + "${@}" $recipient fi fi