From 004cb7ff560cf86ad6547e0272382b6d482e17c0 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 23 Aug 2021 12:25:42 -0600 Subject: [PATCH] remove hardcoded reply-to where it should be $addr, and add option for using local smtp --- mail2mms.sh | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/mail2mms.sh b/mail2mms.sh index e431d37..5321b86 100755 --- a/mail2mms.sh +++ b/mail2mms.sh @@ -1,11 +1,13 @@ #!/bin/sh # Send an MMS message to your phone when new emails come in. -# The message header will have the number of new mails in the subject, -# the From and Subject fields of up to the most recent 3 new mails, -# and 'and more...' if there are more than three new mails +# The message will have the number of new mails in the subject +# and the body will contain the From and Subject fields of up to the 3 +# most recent new mails. If the new mail count is above 3, there will also +# be 'and more...' at the end. # Assumes you have a maildir inbox on this machine; # you can use offlineimap or similar to sync recent mail to a maildir +# or use -l if this machine is actually your mailserver # import the config file ./.config # addr= @@ -17,8 +19,11 @@ . ./.config -if ! pgrep offlineimap; then - offlineimap & +if [ "$1" != -l ]; then + + if ! pgrep offlineimap; then + offlineimap & + fi fi oldnew=0 @@ -42,15 +47,22 @@ summary() { while true; do newnew=$(ls -1 ${inbox}/new | wc -l) if [ ${newnew} -gt ${oldnew} ]; then - echo "$(summary)" \ - | mail -r nilix@nilfm.cc \ - -s "new mail [${newnew}]" \ - -S smtp=${smtp_server} \ - -S smtp-use-starttls \ - -S smtp-auth=login \ - -S smtp-auth-user=${smtp_user} \ - -S smtp-auth-password=${smtp_password} \ - ${phone} + if [ "$1" = -l ]; then + echo "$(summary)" \ + | mail -r ${addr} \ + -s "new mail [${newnew}]" \ + ${phone} + else + echo "$(summary)" \ + | mail -r ${addr} \ + -s "new mail [${newnew}]" \ + -S smtp=${smtp_server} \ + -S smtp-use-starttls \ + -S smtp-auth=login \ + -S smtp-auth-user=${smtp_user} \ + -S smtp-auth-password=${smtp_password} \ + ${phone} + fi fi oldnew=${newnew} sleep 2m