Get Attachment log in zimbra

I have write down a simple script which is give you all the attachment within mail in another log file.

[root@desktop51 ~]# vim attachment-log.sh

#!/bin/bash
# this script for get log attachment

su – zimbra  -c “echo your zimbra version is; zmcontrol -v”

echo “set for attachment log ”

su – zimbra -c “postconf -e “mime_header_checks=pcre:/opt/zimbra/postfix/conf/mime_header_checks””

echo ‘/^Content-(Disposition|Type).*name\s*=\s*”?(.*(\.|=2E)(ade|adp|asp|bas|bat|chm|cmd|com|cpl|crt|dll|exe||zip|pdf|mp3|jpg|rar|exe|wmv|doc|avi|ppt|mpg|tif|wav|mov|psd|wma|sitx|sit|eps|cdr|avi|xls|mp4|txt|m4a|rmvb|bmp|pps|aif|pub|dwg|gif|qbb|mpeg|indd|swf|asf|png|dat|rm|mdb|chm|jar|htm|dvf|dss|dmg|iso|flv|wpd|cda|m4b|7z|gz|fla|qxd|rtf|aiff|msi|jpeg|3gp|cdl|vob|ace|m4p|divx|html|pst|cab|ttf|xtm|hqx|qbw|sea|ptb|bin|mswmm|ifo|tgz|log|dll|mcd|ss|m4v|eml|mid|ogg|ram|lnk|torrent|ses|mp2|vcd|bat|asx|ps|bup|cbr|amr|wps|sql|hlp|ht[at]|inf|ins|isp|jse?|lnk|md[betw]|ms[cipt]|nws|\{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\}|ops|pcd|pif|prf|reg|sc[frt]|sh[bsm]|swf|vb[esx]?|vxd|ws[cfh]))(\?=)?”?\s*(;|$)/x              WARN Attachment name “$2” The file format is “.$4″‘ > /opt/zimbra/postfix/conf/mime_header_checks

chown zimbra:zimbra /opt/zimbra/postfix/conf/mime_header_checks

su – zimbra -c “zmmtactl restart”

echo “0 23 * * * root /bin/grep ‘filename=’ /var/log/maillog >> /var/log/attachment.log” > /etc/cron.d/attachmentlog

[root@desktop51 ~]# chmod  +x attachment-log.sh
[root@desktop51 ~]# sh attachment-log.sh
your zimbra version is
Release 8.0.2_GA_5569.RHEL6_64_20121210115059 CentOS6_64 FOSS edition.
set for attachment log
Rewriting configuration files…done.
/postfix-script: refreshing the Postfix mail system
Stopping saslauthd…done.
Starting saslauthd…done.
Stopping opendkim… done.
Started opendkim: pid 11287

[root@desktop51 ~]# tail /var/log/attachment.log
Aug 23 12:02:04 desktop51 postfix/cleanup[29729]: 0E4C265F45: warning: header Content-Disposition: attachment; filename=RHEV-USB-Client-136.exe from desktop51.bipinpatel.com[192.168.0.51]; from=<test1@bipinpatel.com> to=<test2@bipinpatel.com> proto=ESMTP helo=<desktop51.bipinpatel.com>: Attachment name “RHEV-USB-Client-136.exe” The file format is “.exe”
Aug 23 12:02:09 desktop51 postfix/cleanup[29729]: C6F5165F33: warning: header Content-Disposition: attachment; filename=RHEV-USB-Client-136.exe from localhost[127.0.0.1]; from=<test1@bipinpatel.com> to=<test2@bipinpatel.com> proto=ESMTP helo=<localhost>: Attachment name “RHEV-USB-Client-136.exe” The file format is “.exe”

Advertisements

About bpn4it

Feel Free in Linux. Bipin Patel bpn4it@gmail.com Ahmadabad, Gujarat, India
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s