-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpostfix-report.sh
43 lines (33 loc) · 1.38 KB
/
postfix-report.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
#!/bin/bash
######################################################################
######## POSTFIX REPORT SCRIPT #######################################
######################################################################
# Hope people enjoy the many hours I have put into this project!
# This project is created with my knowledge and some snippets from
# across the open web. If there are snippets you would like credit for.
# Drop me a line and I'll add you!
# Anyone. Feel free to clone and improve.
####################################################
# DM me on: #
# Telegram: https://t.me/joinchat/xlmtm7jVYR4yODQ0 #
####################################################
source telegram.conf
echo "$token" /dev/null 2&>1
echo "$chat_id" /dev/null 2&>1
postfix_info=/tmp/mailer.txt
#These are emoji codes
# go to https://unicode.org/emoji/charts/full-emoji-list.html
# you will need its "U+1F4EB" code MINUS the + As seen below
chart=$'\U1F4CA'
email=$'\U1F4E8'
cat /var/log/mail.log | /usr/sbin/pflogsumm -d today > /tmp/mailer.txt
#Telegram API to send notification.
function telegram_send
{
curl -s -F chat_id=$chat_id -F document=@$postfix_info -F caption="$chart Postfix Report
POSTFIX $email
Report as requested for:
$(hostname)" https://api.telegram.org/bot$token/sendDocument > /dev/null 2&>1
}
telegram_send
rm -f $postfix_info