Zimbra Tips
How to move mail messages from one user's mail folder to another user
(or to send them to external delivery)
- First you need to identify zimbra store folder of this user, like
mysql -e "select * from zimbra.mailbox where comment like 'user@domain.com'" - Then you need to prepare file with a lot of lines, like 1/25+1 of number of messages in his folder needed to copy. If, for example, the messages from folder /test need to be moved, then this file should have the first line: "search -t message 'in:test'" and all other lines: "search -n" (means "give next page of the search results"), like:
search -t message 'in:test'
search -n
search -n
....
search -n - Then you feed this file to zmmailbox to get message IDs:
zmmailbox -z -m user@impulse.netmessagelist.txt - And then we ready to get all the messages in the format ready to feed them to sendmail:
for i in `grep '^[0-9]' messagelist.txt | awk '{print $2}' | sed 's/-//'`; do
find /opt/zimbra/store/0//msg/ -name $i\* >> filelist.txt
done
for i in `cat filelist.txt`; do
zmmailbox -z -mam $i;
done
(if there are a lot of messages, it's better to create a file with lines "am$i" and to feed them to zmmailbox because it starts slowly. - If the messages should be sended to external domain, then the last step may be something like this:
for i in `grep '^[0-9]' messagelist.txt | awk '{print $2}' | sed 's/-//'`; do
find /opt/zimbra/store/0//msg/ -name $i\* >> filelist.txt;
done
for i in `cat filelist.txt`; do
sendmail -i<$i; done
How to "fix" system's sendmail (/usr/sbin/sendmail) for zimbra
(supposing system has alternatives, like debian, centos, ...)
- First check what's there now:
[root@zimbra ~]# ls -l /usr/sbin/sendmail
lrwxrwxrwx 1 root root 21 Jun 23 12:21 /usr/sbin/sendmail -> /etc/alternatives/mta
[root@zimbra ~]# update-alternatives --display mta
mta - status is auto.
link currently points to /usr/sbin/sendmail.sendmail
/usr/sbin/sendmail.sendmail - priority 90
slave mta-mailq: /usr/bin/mailq.sendmail
slave mta-newaliases: /usr/bin/newaliases.sendmail
slave mta-rmail: /usr/bin/rmail.sendmail
slave mta-sendmail: /usr/lib/sendmail.sendmail
slave mta-pam: /etc/pam.d/smtp.sendmail
slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz
slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz
Current `best' version is /usr/sbin/sendmail.sendmail. - Then install alternative and check it:
[root@zimbra ~]# update-alternatives --install /usr/sbin/sendmail mta-sendmail /opt/zimbra/postfix/sbin/sendmail 25
[root@zimbra ~]# update-alternatives --display mta-sendmail
mta-sendmail - status is auto.
link currently points to /opt/zimbra/postfix/sbin/sendmail
/opt/zimbra/postfix/sbin/sendmail - priority 25
Current `best' version is /opt/zimbra/postfix/sbin/sendmail.
No comments:
Post a Comment