Explorar el Código

fix: the content from 'From' seems a bit mess

// solution: just get whole content from/after 'From:' one line

Signed-off-by: shane.xb.qian <shane.qian@foxmail.com>
pull/912/head
shane.xb.qian hace 1 año
padre
commit
39dad6e0ab
Se han modificado 1 ficheros con 3 adiciones y 6 borrados
  1. +3
    -6
      bin/mailsync

+ 3
- 6
bin/mailsync Ver fichero

@@ -70,17 +70,14 @@ syncandnotify() {
echo "$newcount new mail for $2."
[ -z "$MAILSYNC_MUTE" ] &&
for file in $new; do
# Extract subject and sender from mail. TODO: beautify and clean up.
from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" |
perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' |
awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' |
sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
# Extract subject and sender from mail.
from="$(sed -n "/^From: / s/^From: //g p" "$file")"
subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" |
head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' |
sed 's/^Subject: //' |
sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' |
tr -d '\n')
notify "📧$from:" "$subject"
notify "📧 $from :" "$subject"
done
;;
*) echo "No new mail for $2." ;;


Cargando…
Cancelar
Guardar