-
Notifications
You must be signed in to change notification settings - Fork 4
/
smtp.sh
executable file
·53 lines (42 loc) · 1.23 KB
/
smtp.sh
1
2
3
4
5
6
7
8
9
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
#!/bin/bash
F=/tmp/sms.dat
echo '220 voip.249.31.58.tel.ru ESMTP Postfix (Ubuntu)'
read -t 5 L; echo $L >> $F
cat<<EOF
03:S 250-voip.stelsdev.ru250-PIPELINING
250-8BITMIME
250 AUTH PLAIN LOGIN CRAM-MD5
250-8BITMIME
250 DSN
EOF
read -t 5 L; echo $L >> $F
echo 334 VXNlcm5hbWU6
read -t 5 L; echo $L >> $F
echo 334 UGFzc3dvcmQ6
read -t 5 L; echo $L >> $F
echo 235 2.0.0 OK
read -t 5 L; echo $L >> $F # MAIL FROM: <sms>
echo 250 2.1.0 Ok
read -t 5 L; echo $L >> $F # RCPT TO: <sms@voip.stelsdev.ru>
echo 250 2.1.5 Ok
while read -t 5 STR
do
if [ "$STR" == '.' ]
then
echo $STR >> $F
break
else
echo $STR >> $F
echo $STR | base64 -d > /tmp/.sms
cat /tmp/.sms | fgrep Channel > /dev/null
if cat /tmp/.sms | fgrep Channel > /dev/null
then
echo `date '+%Y-%m-%d %H:%M:%S'` `cat /tmp/.sms` >> /tmp/sms.txt # если успешно декодировалось то записать смс в файл, добавить время и new line
(cat /usr/local/smb_scheduler/header; tail -200 /tmp/sms.txt|sort -r; cat /usr/local/smb_scheduler/footer;) > /usr/local/smb_scheduler/sms.html
grep -o 'Ваш номер.*' /tmp/.sms|tr -d [Ваш номер.] >> /etc/phones
fi
fi
done
echo OK
read -t 5 L; echo $L >> $F
echo BYE