adding msmtp-queue-handler depending on off/on status; make msmtp-queue paths configurable; reset counter when queue=0
This commit is contained in:
@@ -15,3 +15,8 @@ VPNIP="1.2.3.4|90.80.70.60"
|
||||
|
||||
# status-misc.sh
|
||||
SVNSTATUS = http://website.showing."fin;revision".or.similar
|
||||
|
||||
# MSMTP paths
|
||||
MSMTP_LIST=/usr/local/bin/msmtp-listqueue.sh
|
||||
MSMTP_RUN=/usr/local/bin/msmtp-runqueue.sh
|
||||
MSMTP_EN=/usr/local/bin/msmtp-enqueue.sh
|
||||
|
||||
17
msmtp-handler.sh
Executable file
17
msmtp-handler.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# If offline, direct mail to msmtp-enqueue.sh
|
||||
# If online, direct mail to msmtp directly
|
||||
|
||||
|
||||
CURDIR=$(dirname "$(readlink -f "$0")")
|
||||
source "$CURDIR"/shared-functions.so
|
||||
|
||||
mail=$(cat)
|
||||
par="$@"
|
||||
|
||||
if [ "$var_conn" == "off" ]; then
|
||||
echo "$mail" | $MSMTP_EN $par
|
||||
else
|
||||
echo "$mail" | msmtp $par
|
||||
fi
|
||||
@@ -5,16 +5,16 @@ source "$CURDIR"/shared-functions.so
|
||||
|
||||
# MAIL QUEUE ACTIONS
|
||||
function send_mailqueue { # send queued mails
|
||||
msmtp-listqueue.sh
|
||||
$MSMTP_LIST
|
||||
read -p "Send these queued mails? [Y/n]: " YN
|
||||
if [[ $YN =~ ^(Y|y|)$ ]]; then
|
||||
msmtp-runqueue.sh
|
||||
$MSMTP_RUN
|
||||
else
|
||||
echo "Not sending emails"
|
||||
fi
|
||||
}
|
||||
function list_mailqueue { # list emails in queue only
|
||||
msmtp-listqueue.sh
|
||||
$MSMTP_LIST
|
||||
}
|
||||
|
||||
# CHANGE ONLINE STATUS
|
||||
|
||||
@@ -17,13 +17,15 @@ function isonline {
|
||||
|
||||
# NUMBER OF UNSENT EMAILS
|
||||
function check_mailqueue {
|
||||
QUEUE=$(msmtp-listqueue.sh | grep -o "^From: " | wc -l)
|
||||
QUEUE=$($MSMTP_LIST | grep -o "^From: " | wc -l)
|
||||
OUT="$OUT;mq=$QUEUE"
|
||||
TOOL="$TOOL;conn=$var_conn"
|
||||
|
||||
# If $QUEUE > 0 and >10 runs, show notification
|
||||
if [ "$QUEUE" -gt 0 ]; then
|
||||
var_mailqueue_runs=$(($var_mailqueue_runs + 1))
|
||||
else
|
||||
var_mailqueue_runs=0 # reset counter if queue is empty again
|
||||
fi
|
||||
if [ "$QUEUE" -gt 0 ] && [ "$var_mailqueue_runs" -gt 9 ]; then
|
||||
notify-send "There are mails in the mailqueue. Remember sending them manually or switch online status."
|
||||
|
||||
Reference in New Issue
Block a user