Email scripts collection (1)

Delete old postmaster email:

find /home/vmail/*/postmaster@*/{new,cur} -type f -mtime +30 -delete

Delete old trash:

find /home/vmail/*/*/.Trash/{new,cur} -type f -mtime +30 -delete

Move sent messages to zip:

find /home/vmail/*/*/.Sent*/{new,cur} -type f -mtime +30 | zip -m -9 /home/vmail/Sent.zip -@

Move old email to zip:

find /home/vmail/domain.com/ -type f -mtime +365 -print | file -F# -if- | grep -E 'rfc822|octet' | awk -F# '{print $1}' | zip -m -9 /home/vmail/Old.zip -@

Update quota2:

cd /home/vmail/domain.com
du -s * | awk '{ print "insert into quota2 values (\"" $2 "\"," $1 "*1000,1000) on duplicate key update bytes=" $1 "*1000;" }' | mysql -uroot -ppaswot postfixadmin

Learn spam from folder Spam:

poll mail.domain.com with proto IMAP user 'email@domain.com' there with password 'paswot'
folder INBOX.Spam
options ssl sslfingerprint 'FB:9D:14:94:FD:F1:C6:12:0E:73:6A:A5:9F:2B:CF:5D'
mda '/usr/bin/spamc -u amavis -L spam' keep no rewrite
limit 500000

poll mail.domain.com with proto IMAP user 'email@domain.com' there with password 'paswot'
folder INBOX.NotSpam
options ssl sslfingerprint 'FB:9D:14:94:FD:F1:C6:12:0E:73:6A:A5:9F:2B:CF:5D'
mda '/usr/bin/spamc -u amavis -L forget' keep no rewrite


Comments

Popular posts from this blog

Ports to allow for whatsapp call

Manually clean up zimbra zmcat/zmcpustat exploit

Keychron K2 in Linux