Skip to navigation
Bash script to check the server postfix mail queue
06.10.21
bash script to check the server postfix mail queue and when there are too many emails in the queue, it will send a telegram bot message the registered users: #!/bin/bash cd "$(dirname "$0")" string=$( /usr/bin/mailq) echo $string string2=$(echo $string | grep -Po '.[0-9] Requests.$') echo $string2 number=$(echo $string2 | tr -dc '0-9') echo $number if [ $number -gt 1 ] then msg="Spam Alert!! ${number}x mails in /usr/bin/mailq " echo Hey that\'s a large number - Send Bot messages to the admin. curl "https://api.telegram.org/botfooo/sendMessage?chat_id=822969321,&text=${msg}" curl "https://api.telegram.org/botfooo/sendMessage?chat_id=872129867,&text=${msg}" fi
http://www.postfix.org/
Reply
Anonymous
#!/bin/bash cd "$(dirname "$0")" string=$( /usr/bin/mailq) echo $string emails=$(echo $string | grep -Po '\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+') emails=${emails//[$'\t\r\n']} && emails=${emails%%*( )} echo "${emails}" string2=$(echo $string | grep -Po '.[0-9] Requests.$') echo $string2 number=$(echo $string2 | tr -dc '0-9') echo $number if [ $number -gt 10 ] then msg="Spam Alert!! ${number}x mails - ${emails:0:1000}" echo Hey that\'s a large number - Send Telegram Bot. curl "https://api.telegram.org/x:AAGXI3Io9feTC7oPb1z1qapn_dUfsreNTcg/sendMessage?chat_id=822969321,&text=${msg}" curl "https://api.telegram.org/x:AAGXI3Io9feTC7oPb1z1qapn_dUfsreNTcg/sendMessage?chat_id=872129867,&text=${msg}" fi
06.10.21
Reply
Anonymous
to send test mails #!/bin/bash cd "$(dirname "$0")" for (( i = 1 ; i <= 21; i++ )); do mail -s"testmail-${i}" Junk@foo.com < /dev/null ; done
06.10.21
Reply
Anonymous
Information Epoch 1732528535
Design programs to be connected to other programs.
Home
Notebook
Contact us