Mostrando postagens com marcador Zimbra. Mostrar todas as postagens
Mostrando postagens com marcador Zimbra. Mostrar todas as postagens

Zimbra mailbox usage report

A way to get an emailable report of all mailboxes in a domain, their quota, usage and account status, so a domain admin can review their accounts without having to login to zimbra. (most of this is the same as viewing quota usage in zimbra admin, but this was easier, as it can then be emailed on a schedule)

I saved this file in /opt/zimbra/backup/scripts/ as usagereport.sh, owned by zimbra.zimbra chmod 755 accountusage.sh

#!/bin/bash

SMTP="10.0.0.2"
FROM="user@yourdomain.com"
TO="user@yourdomain.com"
SUB="Mailbox Usages"
MSG="Mailbox Usages"

output="/tmp/accountusage.csv"
domain="yourdomain.com"
SendTo="user@yourdomain.com"

rm -f $output
touch $output

server=`zmhostname`
/opt/zimbra/bin/zmprov gqu $server|grep $domain|awk {'print $1" "$3" "$2'}|sort|while read line
do
usage=`echo $line|cut -f2 -d " "`
quota=`echo $line|cut -f3 -d " "`
user=`echo $line|cut -f1 -d " "`
#status=`/opt/zimbra/bin/zmprov ga $user | grep  ^zimbraAccountStatus | cut -f2 -d " "`

#with status
#echo "$user; `expr $usage / 1024 / 1024`MB; `expr $quota / 1024 / 1024`MB; ($status account)" >> $output

# without status
echo "$user; `expr $usage / 1024 / 1024`MB; `expr $quota / 1024 / 1024`MB" >> $output
done

#cat $output | mail @SendTo -s"Mailbox Usages for $domain"

sendemail -q -o tls=no -f $FROM -t $TO -u $SUB -m $MSG -s $SMTP:25 -a $output

Zimbra - View all sessions

As zimbra user

/opt/zimbra/bin/zmsoap -z -v GetSessionsRequest @type=soap

/opt/zimbra/bin/zmsoap -z -v GetSessionsRequest @type=imap

/opt/zimbra/bin/zmsoap -z -v GetSessionsRequest @type=admin

Zimbra plus addressing

Plus Addressing is a feature that allows a sender to append a tag to the user id of a recipient. This lets the recipient more easily sort the incoming mail using a mail filter.

For example, user@zimbra.lab could also be reached using the address user+tag@zimbra.lab.

To enable Plus Addressing with Zimbra, use zmprov as follows:

zmprov mcf zimbraMtaRecipientDelimiter +

Note that the delimiter can be a character other than '+'.

To disable Plus Addressing, use zmprov as follows:

zmprov mcf -- -zimbraMtaRecipientDelimiter +

After making changes to enable or disable this feature, you can restart the postfix service :

zmmtactl restart

And check that the postfix configuration has the right value :

postconf recipient_delimiter
recipient_delimiter = +

- Disable addresses (since 8.5.0)

If you want to disable a specific address, e.g. because it has been targeted by spam, you can enable a postfix recipient and client restriction map.

Create the postfix recipient access file:

touch /opt/zimbra/conf/postfix_recipient_access

Edit the file to include the address:

user+spam@zimbra.lab 550 User Unknown

Build the lmdb file:

postmap /opt/zimbra/conf/postfix_recipient_access

Enable check_recipient_access:

zmprov mcf +zimbraMtaRestriction "check_recipient_access lmdb:/opt/zimbra/conf/postfix_recipient_access"


 

Allow relay ASSP



Network Setup, Limits and DKIM signing for Relaying, Outgoing and Local Mail relaying not allowed

acceptAllMail: 10.20.0.211|10.20.0.213|10.20.0.45|10.20.15.|10.20.0.


Apply Changes


Zimbra export account command line

Export full backup of one zimbra account
zmmailbox -z -m user@domain -t 0 getRestURL "//?fmt=tgz" > /tmp/user@domain.tgz

Export current day backup of one zimbra account*
zmmailbox -z -m user@domain -t 0 getRestURL --startTime $(date -d '-1 day' +%Y/%m/%d) --endTime $(date -d '+1 day' +%Y/%m/%d) "//?fmt=tgz" > /tmp/user@domian.tgz

Export last 7 days backup of one zimbra account*
zmmailbox -z -m user@domain -t 0 getRestURL --startTime $(date -d '-8 day' +%Y/%m/%d) --endTime $(date -d '+1 day' +%Y/%m/%d) "//?fmt=tgz" > /tmp/user@domain.tgz

Export current month backup of one zimbra account*
zmmailbox -z -m user@domain -t 0 getRestURL --startTime $(date -d "-$(date +%d) days -0 month" +%Y/%m/%d) --endTime $(date -d "-$(date +%d) days +1 month +1 day" +%Y/%m/%d) "//?fmt=tgz" > /tmp/user@domain.tgz

Export previous month backup of one zimbra account*
zmmailbox -z -m user@domain -t 0 getRestURL --startTime $(date -d "-$(date +%d) days -1 month" +%Y/%m/%d) --endTime $(date -d "-$(date +%d) days -0 month +1 day" +%Y/%m/%d) "//?fmt=tgz" > /tmp/user@domain.tgz

Import zimbra backup of one account
zmmailbox -z -m user@domain -t 0 postRestURL "//?fmt=tgz&resolve=skip" /tmp/user@domain.tgz

*Set more 1 day on the start and end date because it is not possible to specify the time on the dates

The resolve=paramater has several options:
“skip” ignores duplicates of old items, it’s also the default conflict-resolution
“reset” will delete the old subfolder (or entire mailbox if /)
“modify” changes old items
“replace” will delete and re-enter them

Export LDAP configuration zimbra
/opt/zimbra/openldap/sbin/slapcat -F /opt/zimbra/data/ldap/config -b "" -l /tmp/zimbra-ldap.ldif

Setting maximum mail recipients in zimbra

Setting maximum mail recipients in zimbra

To adjust:

su - zimbra
postconf -e 'smtpd_recipient_limit = 1000'

To apply settings:

postfix reload

To check current settings:

postconf | grep smtpd_recipient_limit

Zimbra get attachment sizes

Get attachment sizes

# zmprov gacf | grep zimbraMtaMaxMessageSize
zimbraMtaMaxMessageSize: 20480000

# zmprov gacf | grep zimbraFileUploadMaxSize
zimbraFileUploadMaxSize: 20480000

Change sizes:

zmprov mcf zimbraMtaMaxMessageSize 20480000

10240000 = 10mb
20480000 = 20mb
30720000 = 30mb

Zimbra export ldap schema

 export ldap schema

/opt/zimbra/libexec/zmslapcat /opt/backup/ldap

Zimbra manage accounts

Manage accounts
zimbraAccountStatus can be active, locked, maintenance or closed

zmprov ma accountname@domain.com  zimbraAccountStatus active

Zimbra clear zmlogger data

Clear zmlogger data

zmloggerctl stop
cd /opt/zimbra/logger/db/data
mv rrds rrds_old
mkdir rrds
zmlogger start

Zimbra recipient limits

Recipient limits

postconf | grep smtpd_recipient_limit
postconf -e smtpd_recipient_limit=100

Zimbra clean mailbox

Clean mailbox

su zimbra
zmmailbox -z -m admin@domain.com emptyFolder /Inbox

Zimbra change user COS

Change user COS

su zimbra
zmprov sac name.surname@domain.ltd cosname

Zimbra get account by state

Get account by state

zmprov -l sa "(zimbraAccountStatus=active)"
zmprov -l sa "(zimbraAccountStatus=lockout)"
zmprov -l sa "(zimbraAccountStatus=closed)"

Zimbra message trace

# by sender
/opt/zimbra/libexec/zmmsgtrace -s user@domain.com


# by recipient
/opt/zimbra/libexec/zmmsgtrace -r '@gmail.com'

Zimbra mail queue


View mail queue status

# /opt/zimbra/libexec/zmqstat
hold=0
corrupt=0
deferred=0
active=0
incoming=0

To Check current mail queue status

[root@mail lqs]# su zimbra
[zimbra@mail lqs]$ /opt/zimbra/postfix/sbin/postqueue -p
Mail queue is empty

To Flush Postfix Queue

[root@mail lqs]$ /opt/zimbra/postfix/sbin/postqueue -f

To Requeue Messages In Postfix

[root@mail lqs]$ /opt/zimbra/postfix/sbin/postsuper -r ALL

To Check current hold messages

[root@mail lqs]# /opt/zimbra/postfix/sbin/postsuper -h ALL

To Delete Single Message From Queue

[root@mail lqs]# /opt/zimbra/postfix/sbin/postsuper -d [MSGID From postqueue -p]

To Delete ALL Messages From Queue

[root@mail lqs]# /opt/zimbra/postfix/sbin/postsuper -d ALL

To Delete ALL Messages From The Deferred Queue

[root@mail lqs]# /opt/zimbra/postfix/sbin/postsuper -d ALL deferred

To Delete ALL Messages From The Hold Queue

[root@mail lqs]# /opt/zimbra/postfix/sbin/postsuper -d ALL hold

Clear inbox Zimbra

Clear all inbox from never login accounts

#!/bin/sh
#Limpa o inbox de todas as caias que nunca foram acessadas

cts=`zmaccts | grep never | cut -c 1-40`
for i in $cts; do
zmmailbox -z -m $i emptyFolder /Inbox
done

Zimbra login errors report

Creat script and config in crontab

#!/bin/bash

cat /opt/zimbra/log/audit.log |grep -i "authentication failed" > /var/log/auth_error.log

mail -s "Login Errors Report" admin@domain.com < /var/log/auth_error.log

Get the IP and number of login fails in Zimbra

Get the IP and number of login fails in Zimbra
Use "while read" with "iptables -j DROP" or "route add -host <IP> reject" to block

grep "SASL LOGIN" /var/log/zimbra.log | grep failed | awk '{print $7}' | cut -d[ -f 2 | cut -d] -f 1 | sort | uniq -c | sort -n -r

Monitoring response time with curl

   curl -s -o /dev/null -w "Conecction: %{time_connect}s | Start transfer: %{time_starttransfer}s | Total time: %{time_total}s\n" ...

Mais vistos