use mbsync and fix some bugs
This commit is contained in:
parent
a73e912971
commit
07efac0e7f
1 changed files with 6 additions and 11 deletions
17
mail2mms.sh
17
mail2mms.sh
|
@ -5,8 +5,7 @@
|
||||||
# and the body will contain the From and Subject fields of up to the 3
|
# 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
|
# most recent new mails. If the new mail count is above 3, there will also
|
||||||
# be 'and more...' at the end.
|
# be 'and more...' at the end.
|
||||||
# Assumes you have a maildir inbox on this machine;
|
# Assumes you either have mbsync setup to sync your inbox folder,
|
||||||
# you can use offlineimap or similar to sync recent mail to a maildir
|
|
||||||
# or use -l if this machine is actually your mailserver
|
# or use -l if this machine is actually your mailserver
|
||||||
|
|
||||||
# import the config file ./.config
|
# import the config file ./.config
|
||||||
|
@ -23,7 +22,7 @@ oldnew=0
|
||||||
|
|
||||||
summary() {
|
summary() {
|
||||||
i=0
|
i=0
|
||||||
for m in $(ls -1r ${inbox}/new/*); do
|
for m in $(\ls -1r ${inbox}/new/*); do
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
if [ ${i} -gt 3 ]; then
|
if [ ${i} -gt 3 ]; then
|
||||||
echo "and more..."
|
echo "and more..."
|
||||||
|
@ -39,17 +38,13 @@ summary() {
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
# Start offlineimap if it's not running and we are not on the mailserver
|
# sync mailbox if this is not the mailserver
|
||||||
# Sometimes it can crash, so it's in the loop here instead of at startup
|
if [ "$1" = "-l" ]; then
|
||||||
|
mbsync -a
|
||||||
if [ "$1" != -l ]; then
|
|
||||||
if ! pgrep offlineimap; then
|
|
||||||
offlineimap &
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Count the number of new mails
|
# Count the number of new mails
|
||||||
newnew=$(ls -1 ${inbox}/new | wc -l)
|
newnew=$(\ls -1 ${inbox}/new | wc -l)
|
||||||
|
|
||||||
# If the number of new mails has increased
|
# If the number of new mails has increased
|
||||||
if [ ${newnew} -gt ${oldnew} ]; then
|
if [ ${newnew} -gt ${oldnew} ]; then
|
||||||
|
|
Loading…
Reference in a new issue