Last active
          January 31, 2025 20:43 
        
      - 
      
- 
        Save alexalouit/11040307 to your computer and use it in GitHub Desktop. 
    POSTFIX rejected mail regular email report
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # | |
| # cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/mail-reject.sh >> /root/scripts/cron.log | |
| email="" | |
| dir="/tmp/" | |
| file="/var/log/mail.info" | |
| occur="reject" | |
| cd $dir | |
| if [ -f ./script-mail-reject ] | |
| then | |
| if [ -f ./script-mail-reject-last ] | |
| then | |
| rm ./script-mail-reject-last | |
| fi | |
| mv ./script-mail-reject ./script-mail-reject-last | |
| touch ./script-mail-reject | |
| chmod -R 777 ./script-mail-reject | |
| else | |
| touch ./script-mail-reject | |
| chmod -R 777 ./script-mail-reject | |
| fi | |
| grep $occur $file > ./script-mail-reject | |
| if [ -f ./script-mail-reject-last ] | |
| then | |
| if diff ./script-mail-reject ./script-mail-reject-last >/dev/null ; | |
| then | |
| rm ./script-mail-reject | |
| else | |
| contain=$(diff ./script-mail-reject ./script-mail-reject-last) | |
| echo -e "SMTP report (reject):\n $contain" | mail -s "SMTP report (reject)" $email | |
| fi | |
| fi | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment