summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorluukvbaal <31730729+luukvbaal@users.noreply.github.com>2019-06-01 16:16:58 +0200
committerGitHub <noreply@github.com>2019-06-01 16:16:58 +0200
commite50d51d3e56c7531cf321b7a0ed7276ad14bb90d (patch)
tree1a31b8070ce40ddadcc04d836379fb563ebee031 /bin
parentde2be5439dab0bb357405b1d0e87ea8138dd630e (diff)
fix multiline subjects and single word senders
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mailsync4
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/mailsync b/bin/mailsync
index 44c9756..199ede2 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -29,8 +29,8 @@ syncandnotify() {
notify "$acc" "$newcount" &
for file in $new; do
# Extract subject and sender from mail.
- from=$(grep "^From: " "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; $NF=""; print $0 }' | tr -d "\"\'\<\>" | sed 's/^ \(.*\) $/\1/')
- subject=$(grep "^Subject: " "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/Subject: //')
+ from=$(grep "^From: " "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if ($NF>=3)$NF=""; print $0 }' | tr -d "\"\'\<\>" | sed 's/^ \(.*\) $/\1/')
+ subject=$(sed -n '/^Subject: /,/^.*:/p' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | head -n-1)
notify-send "📧$from:" "$subject" &
done
fi