remove hardcoded reply-to where it should be $addr, and add option for using local smtp
This commit is contained in:
parent
4e92ed396d
commit
004cb7ff56
1 changed files with 26 additions and 14 deletions
40
mail2mms.sh
40
mail2mms.sh
|
@ -1,11 +1,13 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Send an MMS message to your phone when new emails come in.
|
# 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 message 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 the body will contain the From and Subject fields of up to the 3
|
||||||
# and 'and more...' if there are more than three new mails
|
# 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;
|
# Assumes you have a maildir inbox on this machine;
|
||||||
# you can use offlineimap or similar to sync recent mail to a maildir
|
# 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
|
# import the config file ./.config
|
||||||
# addr=<the address the notification will appear to be sent from>
|
# addr=<the address the notification will appear to be sent from>
|
||||||
|
@ -17,8 +19,11 @@
|
||||||
|
|
||||||
. ./.config
|
. ./.config
|
||||||
|
|
||||||
if ! pgrep offlineimap; then
|
if [ "$1" != -l ]; then
|
||||||
offlineimap &
|
|
||||||
|
if ! pgrep offlineimap; then
|
||||||
|
offlineimap &
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
oldnew=0
|
oldnew=0
|
||||||
|
@ -42,15 +47,22 @@ summary() {
|
||||||
while true; do
|
while true; do
|
||||||
newnew=$(ls -1 ${inbox}/new | wc -l)
|
newnew=$(ls -1 ${inbox}/new | wc -l)
|
||||||
if [ ${newnew} -gt ${oldnew} ]; then
|
if [ ${newnew} -gt ${oldnew} ]; then
|
||||||
echo "$(summary)" \
|
if [ "$1" = -l ]; then
|
||||||
| mail -r nilix@nilfm.cc \
|
echo "$(summary)" \
|
||||||
-s "new mail [${newnew}]" \
|
| mail -r ${addr} \
|
||||||
-S smtp=${smtp_server} \
|
-s "new mail [${newnew}]" \
|
||||||
-S smtp-use-starttls \
|
${phone}
|
||||||
-S smtp-auth=login \
|
else
|
||||||
-S smtp-auth-user=${smtp_user} \
|
echo "$(summary)" \
|
||||||
-S smtp-auth-password=${smtp_password} \
|
| mail -r ${addr} \
|
||||||
${phone}
|
-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
|
fi
|
||||||
oldnew=${newnew}
|
oldnew=${newnew}
|
||||||
sleep 2m
|
sleep 2m
|
||||||
|
|
Loading…
Reference in a new issue