"Fossies" - the Fresh Open Source Software Archive

Member "msmtp-1.8.5/scripts/msmtpqueue/msmtp-enqueue.sh" (2 May 2019, 1080 Bytes) of package /linux/privat/msmtp-1.8.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "msmtp-enqueue.sh": 1.8.4_vs_1.8.5.

    1 #!/usr/bin/env sh
    2 
    3 QUEUEDIR=$HOME/.msmtpqueue
    4 
    5 # Set secure permissions on created directories and files
    6 umask 077
    7 
    8 # Change to queue directory (create it if necessary)
    9 if [ ! -d "$QUEUEDIR" ]; then
   10     mkdir -p "$QUEUEDIR" || exit 1
   11 fi
   12 cd "$QUEUEDIR" || exit 1
   13 
   14 # Create new unique filenames of the form
   15 # MAILFILE:  ccyy-mm-dd-hh.mm.ss[-x].mail
   16 # MSMTPFILE: ccyy-mm-dd-hh.mm.ss[-x].msmtp
   17 # where x is a consecutive number only appended if you send more than one
   18 # mail per second.
   19 BASE="$(date +%Y-%m-%d-%H.%M.%S)"
   20 if [ -f "$BASE.mail" ] || [ -f "$BASE.msmtp" ]; then
   21     TMP="$BASE"
   22     i=1
   23     while [ -f "$TMP-$i.mail" ] || [ -f "$TMP-$i.msmtp" ]; do
   24         i=$((i + 1))
   25     done
   26     BASE="$BASE-$i"
   27 fi
   28 MAILFILE="$BASE.mail"
   29 MSMTPFILE="$BASE.msmtp"
   30 
   31 # Write command line to $MSMTPFILE
   32 echo "$@" > "$MSMTPFILE" || exit 1
   33 
   34 # Write the mail to $MAILFILE
   35 cat > "$MAILFILE" || exit 1
   36 
   37 # If we are online, run the queue immediately.
   38 # Replace the test with something suitable for your site.
   39 #ping -c 1 -w 2 SOME-IP-ADDRESS > /dev/null
   40 #if [ $? -eq 0 ]; then
   41 #   msmtp-runqueue.sh > /dev/null &
   42 #fi
   43 
   44 exit 0