- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
#!/bin/sh
#
# $1 is the mail account
[ -n "$1" ] && {
MAIL_PATH="/Mail/$1/mbox"
OUTPUT_MAIL_PATH="/mnt/flash/save/email/inbox/"
mkdir -p $OUTPUT_MAIL_PATH
mv /var/spool/mail/root/* $MAIL_PATH
for j in `find $MAIL_PATH -name "msg.*"`
do
MAIL_NAME=`basename $j`.eml
NEW_MAIL="$OUTPUT_MAIL_PATH/$MAIL_NAME"
mkdir -p "$OUTPUT_MAIL_PATH"
[ ! -f "$NEW_MAIL" ] && {
grep "^From:" $j | head -n 1 > $NEW_MAIL
if grep "^Cc:" $j ; then
grep "^Cc:" $j | head -n 1 >> $NEW_MAIL
fi
grep "^To:" $j | head -n 1 >> $NEW_MAIL
grep "^Subject:" $j | head -n 1 >> $NEW_MAIL
grep "^Date:" $j | head -n 1 >> $NEW_MAIL
if grep "^Content-Type: text/plain;" $j ; then
LINE_NUM=`grep -n "^Content-Type: text/plain;" $j | cut -d: -f1`
if grep "^Content-Type: text/plain;" $j | grep "charset=" ; then
TYPE=`grep "Content-Type: text/plain;" $j | cut -d";" -f1`
echo "$TYPE" >> $NEW_MAIL
CHAR="charset="`grep "Content-Type: text/plain;" $j | cut -d= -f2`
echo "$CHAR" >> $NEW_MAIL
else
grep "^Content-Type: text/plain;" $j >> $NEW_MAIL
x=$(($LINE_NUM+1))
sed -n "$x"p $j >> $NEW_MAIL
fi
x=$(($LINE_NUM-1))
BOUNDARY=`sed -n "$x"p $j`
for i in `sed "/$BOUNDARY/s/.*/ffffuuuucccckkkk/" $j | grep -n "ffffuuuucccckkkk" | cut -d: -f1`
do
if [ "$i" -gt "$LINE_NUM" ] ; then
i=$(($i-1))
y=$(($LINE_NUM+3))
echo "Mail content start:" >> $NEW_MAIL
sed -n "$y,$i"p $j >> $NEW_MAIL
break
fi
done
if ! grep "Mail content start:" $NEW_MAIL ; then
echo "Mail content start:" >> $NEW_MAIL
y=$(($LINE_NUM+3))
x=`grep -c "^" $j`
sed -n "$y,$x"p $j >> $NEW_MAIL
fi
else
echo "Fuck....."
fi
}
done
}
sayidandrtfm 29.07.2011 14:29 # 0
guest 29.07.2011 15:47 # −4
guest8 09.04.2019 11:15 # −999