summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluukvbaal <31730729+luukvbaal@users.noreply.github.com>2019-05-31 00:02:48 +0200
committerGitHub <noreply@github.com>2019-05-31 00:02:48 +0200
commitde2be5439dab0bb357405b1d0e87ea8138dd630e (patch)
tree2ab06af440be9dfe652cb1af6a6813c035b55908
parent70257daa83fee7a9ac0563d9a2d86991d0031dd8 (diff)
perl decoding
-rwxr-xr-xbin/mailsync10
1 files changed, 3 insertions, 7 deletions
diff --git a/bin/mailsync b/bin/mailsync
index 1ef2155..44c9756 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -28,13 +28,9 @@ syncandnotify() {
if [ "$newcount" -gt "0" ]; then
notify "$acc" "$newcount" &
for file in $new; do
- # Extract subject and sender from mail (room for improvement).
- subject=$(grep "^Subject: " "$file" | sed 's/Subject: //' | head -n4)
- from=$(grep "^From: " "$file" | awk '{ $1=""; $NF=""; print $0 }' | tr -d "\"\'\<\>" | sed 's/^ \(.*\) $/\1/')
- substring="=?"
- # Some html emails contain weird Subject and/or Sender formatting, in which case the html tag content is used (room for improvement).
- [ "${subject#*$substring}" != "$subject" ] && subject=$(tr '\n' ' ' < "$file" | sed 's/.*<title>\(.*\)<\/title>.*/\1/')
- [ "${from#*$substring}" != "$from" ] && from=$(grep ^"From: " "$file" | sed 's/.*<\(.*\)>.*/\1/')
+ # 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: //')
notify-send "📧$from:" "$subject" &
done
fi