diff --git a/usr/bin/send-to-list b/usr/bin/send-to-list new file mode 100755 index 0000000..1304c43 --- /dev/null +++ b/usr/bin/send-to-list @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +LIST="$1" +DONE="$2" +EMAIL="$3" +MAX=${4:-1} + +touch "$DONE" +count=0 + +while IFS= read -r line; do + grep -Fxq -- "$line" "$DONE" && continue + + if msmtp "$line" < "$EMAIL"; then + printf '%s\n' "$line" + printf '%s\n' "$line" >> "$DONE" + ((++count >= MAX)) && break + else + echo "FAILED: $line" >&2 + grep -v $line $LIST > tmp + mv tmp $LIST + fi + +done < "$LIST" +