How to set smarthost(smtpauth) in zimbra

How to set smarthost(smtpauth) in zimbra

by -
0 3093

How to set smarthost(smtpauth) in zimbra

[zimbra@kvit conf]$ su – zimbra

[zimbra@kvit conf]$ cp /opt/zimbra/conf/zmconfigd.cf /opt/zimbra/conf/zmconfigd.cf.org

Note: Remove all bleow lines from zmconfigd.cf

[zimbra@kvit conf]$ vim /opt/zimbra/conf/zmconfigd.cf

POSTCONF smtp_sasl_password_maps LOCAL postfix_smtp_sasl_password_maps
POSTCONF smtp_sasl_auth_enable LOCAL postfix_smtp_sasl_auth_enable
POSTCONF smtp_cname_overrides_servername LOCAL postfix_smtp_cname_overrides_servername
POSTCONF smtp_sasl_security_options LOCAL postfix_smtp_sasl_security_option
POSTCONF smtp_sasl_mechanism_filter LOCAL postfix_smtp_sasl_mechanism_filter

[zimbra@kvit conf]$ vim /opt/zimbra/postfix/conf/bysender

@kvit.in mail.kvit.in

[zimbra@kvit conf]$ postmap /opt/zimbra/postfix/conf/bysender
[zimbra@kvit conf]$vim /opt/zimbra/conf/relay_password
mail.kvit.in prabhat@kvit.in:india#@!

[zimbra@kvit conf]$ postmap /opt/zimbra/conf/relay_password
[zimbra@kvit conf]$ postfix reload
/postfix-script: refreshing the Postfix mail system

How to disable antispam,logger ,stats or anitvirus services when we required.

CLI – To DISABLE AV/AS

su – zimbra
[zimbra@kvit ~]$ zmprov ms “kvit.in” -zimbraServiceEnabled antivirus
[zimbra@kvit ~]$ zmprov ms “kvit.in” -zimbraServiceEnabled antispam
[zimbra@kvit ~]$ zmcontrol stop
[zimbra@kvit ~]$ zmcontrol start
[zimbra@kvit ~]$ zmprov ms “kvit.in” +zimbraServiceEnabled antivirus
[zimbra@kvit ~]$ zmprov ms “kvit.in” +zimbraServiceEnabled antispam
[zimbra@kvit ~]$ zmcontrol stop
[zimbra@kvit ~]$ zmcontrol start

[zimbra@kvit ~]$ zmprov ms “kvit.in” -zimbraServiceEnabled logger
[zimbra@kvit ~]$ zmprov ms ” kvit.in ” -zimbraServiceEnabled stats
[zimbra@kvit ~]$ zmcontrol stop
[zimbra@kvit ~]$ zmcontrol start

How to route mail through other server(Transport)

su – zimbra

[zimbra@kvit conf]$ echo mail.6987.in prabhat@kvit.in:krishna@6987 > /opt/zimbra/conf/relay_password
[zimbra@kvit conf]$ postmap /opt/zimbra/conf/relay_password

Note: Before putting any lines in main.cf remove these lines from zmconfig.cf. Otherwise main.cf will get overwirtten by zmconfig program

[zimbra@kvit conf]$ vim /opt/zimbra/conf/zmconfigd.cf

smtp_sasl_password_maps=hash:/opt/zimbra/conf/relay_password
smtp_sasl_auth_enable=yes
smtp_cname_overrides_servername=no
smtp_sasl_security_options = noplaintext, noanonymous
smtp_sasl_mechanism_filter=plain,login
smtp_sasl_security_options=noanonymous
Note:Put these lines in main.cf and remove existing lines.

[zimbra@kvit conf]$ vim /opt/zimbra/postfix/conf/main.cf

smtp_sasl_password_maps=hash:/opt/zimbra/conf/relay_password
smtp_sasl_auth_enable=yes
smtp_cname_overrides_servername=no
smtp_sasl_security_options = noplaintext, noanonymous
smtp_sasl_mechanism_filter=plain,login
smtp_sasl_security_options=noanonymous
[zimbra@kvit ~]$ vi /opt/zimbra/postfix/conf/transportfile

yahoo.com :[mail.6987.in]

[zimbra@kvit ~]$ postmap /opt/zimbra/postfix/conf/transportfile
[zimbra@kvit ~]$ zmlocalconfig -e postfix_transport_maps=”hash:/opt/zimbra/postfix/conf/transportfile proxy:ldap:/opt/zimbra/conf/ldap-transport.cf”
[zimbra@kvit ~]$ zmcontrol restart
Host kvit.in
Stopping vmware-ha…Done.
Stopping zmconfigd…Done.
Stopping stats…Done.
Stopping mta…Done.
Stopping spell…Done.
Stopping snmp…Done.
Stopping cbpolicyd…Done.
Stopping archiving…Done.
Stopping antivirus…Done.
Stopping antispam…Done.
Stopping proxy…Done.
Stopping memcached…Done.
Stopping mailbox…Done.
Stopping logger…Done.
Stopping ldap…Done.
Host kvit.in
Starting ldap…Done.
Starting zmconfigd… Done.
Starting logger…Done.
Starting mailbox…Done.
Starting memcached…Done.
Starting proxy…Done.
Starting antispam…Done.
Starting antivirus…Done.
Starting snmp…Done.
Starting spell…Done.
Starting mta…Done.
Starting stats…Done
[zimbra@kvit ~]$

How to make blacklist and whitelist in zimbra

Note: There are two way to do blacklist and whitelist
A. Through spamassassion

[zimbra@kvit ~]$ postmap /opt/zimbra/postfix/conf/transportfile

[zimbra@kvit ~]$ zmlocalconfig -e postfix_transport_maps=”hash:/opt/zimbra/postfix/conf/transportfile proxy:ldap:/opt/zimbra/conf/ldap-transport.cf

[zimbra@kvit ~]$ zmcontrol restart
Host kvit.in
Stopping vmware-ha…Done.
Stopping zmconfigd…Done.
Stopping stats…Done.
Stopping mta…Done.
Stopping spell…Done.
Stopping snmp…Done.
Stopping cbpolicyd…Done.
Stopping archiving…Done.
Stopping antivirus…Done.
Stopping antispam…Done.
Stopping proxy…Done.
Stopping memcached…Done.
Stopping mailbox…Done.
Stopping logger…Done.
Stopping ldap…Done.
Host kvit.in
Starting ldap…Done.
Starting zmconfigd… Done.
Starting logger…Done.
Starting mailbox…Done.
Starting memcached…Done.
Starting proxy…Done.
Starting antispam…Done.
Starting antivirus…Done.
Starting snmp…Done.
Starting spell…Done.
Starting mta…Done.
Starting stats…Done
[zimbra@kvit ~]$

B.  Through amavis

Note:-
whitelist= For whitelisting
Blacklist= For blacklisting
Spamlovers= if someone those want to byepass junk folder

[root@kvit ~]# su – zimbra
[zimbra@kvit ~]$ vim /opt/zimbra/conf/amavisd.conf.in <—–PUT AT BOTTAM

read_hash(\%whitelist_sender, ‘/opt/zimbra/whitelist’);
read_hash(\%blacklist_sender, ‘/opt/zimbra/blacklist’);
read_hash(\%spam_lovers, ‘/opt/zimbra/spamlovers’);

[zimbra@kvit ~]$ exit

[root@kvit ~]# touch /opt/zimbra/{whitelist,blacklist,spamlovers}
[root@kvit ~]# chown zimbra:zimbra /opt/zimbra/{whitelist,blacklist,spamlovers}

[root@kvit ~]# su – zimbra
[zimbra@kvit ~]$ zmamavisdctl restart

[zimbra@kvit ~]$ zmamavisdctl restart
Stopping amavisd… done.
Starting amavisd…done.
[zimbra@kvit ~]$

Note:- In /etc/zimbra/* put sender address or domain, one per line. Wildcards allowed. Example:

prabhat@abc.com
xyz.com

How to disable msgid(Required when it is missing mail) in Zimbra

Note: 0= disable

[zimbra@kvit conf]$ zmprov gcf zimbraMessageIdDedupeCacheSize
zimbraMessageIdDedupeCacheSize: 3000

[zimbra@kvit conf]$ zmprov mcf zimbraMessageIdDedupeCacheSize 0
[zimbra@kvit conf]$ zmmailboxdctl restart
Stopping mailboxd…done.
Starting mailboxd…done.
[zimbra@kvit conf]$ exit

Change logo path in zimbra

[zimbra@kvit ~]$ zmprov md kvit.in zimbraSkinLogoURL https://6987.in/
[zimbra@kvit ~]$ zmprov md kvit.in zimbraSkinLogoLoginBanner https://6987.in/img/MyLoginBanner.png
[zimbra@kvit ~]$ zmprov md kvit.in zimbraSkinLogoAppBanner https://6987.in/img/MyAppBanner.png

Change users loginURL https to http in zimbra 8.X

[zimbra@kvit ~]$ zmtlsctl http
Setting ldap config zimbraMailMode http for kvit.in…done.
Rewriting config files for cyrus-sasl, webxml and mailboxd…done.
[zimbra@kvit ~]$ zmcontrol restart
Host kvit.in
Stopping vmware-ha…Done.
Stopping zmconfigd…Done.
Stopping stats…Done.
Stopping mta…Done.
Stopping spell…Done.
Stopping snmp…Done.
Stopping cbpolicyd…Done.
Stopping archiving…Done.
Stopping antivirus…Done.
Stopping antispam…Done.
Stopping proxy…Done.
Stopping memcached…Done.
Stopping mailbox…Done.
Stopping logger…Done.
Stopping ldap…Done.
Host kvit.in
Starting ldap…Done.
Starting zmconfigd… Done.
Starting logger…Done.
Starting mailbox…Done.
Starting memcached…Done.
Starting proxy…Done.
Starting antispam…Done.
Starting antivirus…Done.
Starting snmp…Done.
Starting spell…Done.
Starting mta…Done.
Starting stats…Done
[zimbra@kvit ~]$

How to check mailbox size in zimbra

[zimbra@kvit ~]$ zmmailbox -z -m prabhat@kvit.in gms
14.45 KB


Note:- Script for all users mailbox size.

[zimbra@kvit ~]$ vim /opt/zimbra/backup/checkmailsize.sh

WHO=`whoami`
if [ $WHO = “zimbra” ]
then
all_account=`zmprov -l gaa`;
for account in ${all_account}
do
mb_size=`zmmailbox -z -m ${account} gms`;
echo “Mailbox size of ${account} = ${mb_size}”;

done

else
echo “Execute this script as user zimbra”

fi

[zimbra@kvit ~]$ /bin/sh /opt/zimbra/backup/checkmailsize.sh

Mailbox size of galsync@6987.in = 0 B
Mailbox size of admin@kvit.in = 88.73 KB
Mailbox size of spam.zktniovd@kvit.in = 0 B
Mailbox size of ham.f4qxvroiw@kvit.in = 0 B
Mailbox size of virus-quarantine.f3zydsmn@kvit.in = 0 B
Mailbox size of galsync.pluemr6hm@kvit.in = 0 B
Mailbox size of prabhat@kvit.in = 14.45 KB
Mailbox size of prabhat@test.com = 0 B

How to do empty inbox of a user in zimbra

[zimbra@kvit ~]$ zmmailbox -z -m prabhat@kvit.in gaf
Id View Unread Msg Count Path
———- —- ———- ———- ———-
1 unkn 0 0 /
16 docu 0 0 /Briefcase
10 appo 0 0 /Calendar
14 mess 0 0 /Chats
7 cont 0 0 /Contacts
6 mess 0 0 /Drafts
13 cont 0 3 /Emailed Contacts
2 mess 0 2 /Inbox
4 mess 0 0 /Junk
5 mess 0 7 /Sent
15 task 0 0 /Tasks
3 unkn 0 1 /Trash

[zimbra@kvit ~]$ zmmailbox -z -m prabhat@kvit.in emptyFolder /Inbox


Note:- Any folder you can make empty as per your requirement with help of above command

How to delete particular mail (msgid) from all user inbox in zimbra

Note:- Get all Accounts

[zimbra@kvit ~]$ zmprov gaa | grep mydomain.com$ > /tmp/temp_file

Note:- Delete message in each account with the matching msg id

[

zimbra@kvit ~]$ vim /opt/zimbra/backup/script.sh

for acct in `cat /tmp/temp_file` ; do
“zmmailbox -a <admin> -p <password> -m $acct dm <msg id>
done

[zimbra@kvit ~]$ /bin/ sh /opt/zimbra/backup/script.sh

# Remove temp_file 

[zimbra@kvit ~]$ rm -f /tmp/temp_file

How to restric particuler mailid or domain through transport

:- Put your domain or email id in below file.

 

[zimbra@kvit ~]$ vim /opt/zimbra/conf/postfix_transport

ram@domain.com error: Forbidden Recipient Address
gmail.com error:On this domain mails are not allowed

[zimbra@kvit ~]$ postmap /opt/zimbra/conf/postfix_transport
[zimbra@kvit ~]$ vim /opt/zimbra/conf/localconfig.xml
<key name=”postfix_transport_maps”>
<value>proxy:ldap:/opt/zimbra/conf/ldap-transport.cf</value>
</key>

change to ->
<key name=”postfix_transport_maps”>
<value>hash:/opt/zimbra/conf/postfix_transport, proxy:ldap:/opt/zimbra/conf/ldap-transport.cf</value>
</key>

[zimbra@kvit ~]$ zmmtactl restart

How to remove mail subject base in zimbra.

Note:-  There are two method.
A:-

[zimbra@kvit ~]$ vim /opt/zimbra/backup/rm_message.sh

#!/bin/bash
# rm_message.sh prabhat@metrogroup.co.in subject
if [ -z “$2” ]; then
echo “usage: rm_message.sh prabhat@metrogroup.co.in Email From IRCTC”
exit 0
else
addr=$1
subject=$2
echo “Searching $addr for Subject: $subject”
for msg in `zmmailbox -z -m “$addr” s -l 999 -t message “subject:$subject”|awk ‘{ if (NR!=1) {print}}’ | grep -v -e Id -e “-” -e “^$” | awk ‘{ print $2 }’`
do
echo “Removing “$msg””
zmmailbox -z -m $1 dm $msg
done
fi

[zimbra@kvit ~]$ /bin/sh /opt/zimbra/backup/rm_message.sh prabhat@kvit.in “Email From IRCTC”

 

B:-

[zimbra@kvit conf]$ zmmailbox -z -m “prabhat@kvit.in” s -l 999 -t message “subject: Undelivered Mail Returned to Sender*”|awk ‘{ if (NR!=1) {print}}’ | grep -v -e Id -e “-” -e “^$” | awk ‘{ print $2 }

281
262

[zimbra@kvit conf]$ zmmailbox -z -m prabhat@kvit.in dm 281,262

Note:– From all users

[zimbra@kvit ~]$ vim /opt/zimbra/backup/hi.sh

#zmprov -l gaa > /tmp/userlist
SUB=”Undelivered Mail Returned to Sende*”
for user in `cat /tmp/userlist`
do
echo 0>/tmp/msggg
zmmailbox -z -m “$user” s -l 999 -t message “subject:$SUB”|awk ‘{ if (NR!=1) {print}}’ | grep -v -e Id -e “-” -e “^$” | awk ‘{ print $2 }’ >> /tmp/msggg
id=`cat /tmp/msggg | wc -l`
if [ $id -lt 1 ]; then
echo “Do nothing in $user” >> /tmp/nomsguser
else

for demsg in `cat /tmp/msggg`
do
zmmailbox -z -m $user dm $demsg

done
echo “$id mails are deleted from $user” >> /tmp/msgusers
fi
done
[zimbra@kvit ~]$ /bin/sh /opt/zimbra/backup/hi.sh

How to set RBL lines from cli.

[zimbra@kvit ~]$ vim /opt/zimbra/conf/zmconfigd/smtpd_recipient_restrictions.cf

%%contains VAR:zimbraServiceEnabled cbpolicyd, check_policy_service inet:localhost:@@cbpolicyd_bind_port@@%%
reject_non_fqdn_recipient
reject_unlisted_recipient
reject_rbl_client sbl.spamhaus.org
reject_rbl_client b.barracudacentral.org
reject_rbl_client zen.spamhaus.org
%%contains VAR:zimbraMtaRestriction reject_invalid_helo_hostname%%
%%contains VAR:zimbraMtaRestriction reject_non_fqdn_helo_hostname%%
%%contains VAR:zimbraMtaRestriction reject_non_fqdn_sender%%
%%contains VAR:zimbraMtaRestriction reject_unknown_client_hostname%%
%%contains VAR:zimbraMtaRestriction reject_unknown_helo_hostname%%
%%contains VAR:zimbraMtaRestriction reject_unknown_sender_domain%%
%%explode reject_rbl_client VAR:zimbraMtaRestrictionRBLs%%
%%contains VAR:zimbraMtaRestriction check_policy_service unix:private/policy%%
permit

 

[zimbra@kvit ~]$ postfix reload

How to export or import account from cli in zimbra

How to export or import account from cli in zimbra

Note:- Export mailbox with this command

[zimbra@kvit ~]$ zmmailbox -z -m prabhat@kvit.in getRestURL “//?fmt=tgz” > /tmp/prabhat@kvit.in.tar.gz

Note:- import it into the destination server with this command:

[zimbra@kvit ~]$ zmmailbox -z -m prabhat@kvit.in postRestURL “//?fmt=tgz&resolve=reset” /tmp/ prabhat@kvit.in.tar.gz

Note:- Simply replace “tgz” with “zip” in order to chose between the two archive formats 

when importing and exporting, making sure to use the right one on the import!

How to export or import filter(rules) in zimbra

[zimbra@kvit ~]$ zmprov ga prabhat@kvit.in zimbraMailSieveScript > /tmp/prabhat.rule 

1:-  Modified the script by removing the initial commented line, and deleted ‘zimbraMailSieveScript: ‘. So the first line in the script looks like this:

require [“fileinto”, “reject”, “tag”, “flag”];
2:-  Transferred the script to the other server, and assigned the entire output to a variable, like so:

[zimbra@kvit ~]$ SIEVEVAR=`cat /tmp/prabhat.rule`


3:- Run zmprov, enclosing the variable in double quotes:

[zimbra@kvit ~]$ zmprov ma prabhat@6987.in zimbraMailSieveScript “$SIEVEVAR”

How to add catchall in zimbra

[zimbra@kvit ~]$ zmprov modifyAccount allcatchall@kvit.in zimbraMailCatchAllAddress @kvit.in

:- Now all mails will go in allcatchall@kvit.in

How to bypass RBL listed IP in Zimbra

[root@kvit ~]# su – zimbra

Note:- Add line No. 6 (highlight line) to postfix_recipient_restrictions.cf file

[zimbra@kvit ~]$ vi /opt/zimbra/conf/postfix_recipient_restrictions.cf

%%contains VAR:zimbraServiceEnabled cbpolicyd, check_policy_service inet:127.0.0.1:10031%%
reject_non_fqdn_recipient
permit_sasl_authenticated
permit_mynetworks
reject_unauth_destination
check_client_access hash:/opt/zimbra/conf/allow_rbl
reject_unlisted_recipient
%%contains VAR:zimbraMtaRestriction reject_invalid_hostname%%
%%contains VAR:zimbraMtaRestriction reject_non_fqdn_hostname%%
%%contains VAR:zimbraMtaRestriction reject_non_fqdn_sender%%
%%contains VAR:zimbraMtaRestriction reject_unknown_client%%
%%contains VAR:zimbraMtaRestriction reject_unknown_hostname%%
%%contains VAR:zimbraMtaRestriction reject_unknown_sender_domain%%
%%explode reject_rbl_client VAR:zimbraMtaRestrictionRBLs%%
%%contains VAR:zimbraMtaRestriction check_policy_service unix:private/policy%%
permit

Note:- Create file allow_rbl in /opt/zimbra/conf
[zimbra@kvit ~]$ vi /opt/zimbra/conf/allow_rbl

#allow_rbl file inside :
114.57.xxx.xxx OK
202.155.xxx.xxx OK
[zimbra@kvit ~]$ postmap /opt/zimbra/conf/allow_rbl
[zimbra@kvit ~]$ zmmtactl restart
Rewriting configuration files…done.
postfix/postfix-script: refreshing the Postfix mail system
Stopping saslauthd…done.
Starting saslauthd…done.
[zimbra@kvit ~]$

How to add maildir formate mails in zimbra

Note:- Add narendra’s mails which are in maildir formate.

[zimbra@kvit ~]$ zmmailbox -z -m prabhat@kvit.in addMessage “/inbox” /home/narendra/maildir/cur

How to increase brifcase size and mail sending size

Note:- 150000000 bytes; = 150M

[zimbra@kvit ~]$ zmprov modifyConfig zimbraFileUploadMaxSize 150000000
[zimbra@kvit ~]$ zmprov modifyConfig zimbraMtaMaxMessageSize 150000000

How to Check allowed networks in zimbra

[zimbra@kvit ~]$ zmprov gs `zmhostname` zimbraMtaMyNetworks
# name kvit.in
zimbraMtaMyNetworks: 127.0.0.0/8 192.168.0.0/24 [::1]/128 [fe80::]/64

 

Note:- Put required network

[zimbra@kvit ~]$ zmprov ms `zmhostname` zimbraMtaMyNetworks ‘127.0.0.0/8 10.64.52.0/26  [::1]/128 [fe80::]/64’

How to enable Disclaimer in zimbra

[zimbra@kvit ~]$ zmprov mcf zimbraDomainMandatoryMailSignatureEnabled TRUE

[zimbra@kvit ~]$ vim /tmp/disclaimer.txt
Thanks & Regards
Prabhat Kumar
9711963303
[zimbra@kvit ~]$ zmprov mcf zimbraDomainMandatoryMailSignatureText “`cat /tmp/disclaimer.txt`”

 

#add disclaimer per domain wise

[zimbra@kvit ~]$ vim /opt/zimbra/conf/amavisd.conf.in

#find

@disclaimer_options_bysender_maps = (
{ ‘.’ => ‘global-default’ },
);
#and add your custom disclaimer to your domain

@disclaimer_options_bysender_maps = (
{ ‘.kvit.in’ => ‘kvit’ },

);


Then go to /opt/zimbra/data/altermime. You should see 2 files global-default.txt and global-default.html.
These are the existing global signatures. Now we have to add kvit.txt and kvit.html

[zimbra@kvit ~]$ zmamavisdctl restart

How to add bulk users in zimbra

Note:Change in the script as you required.

[zimbra@kvit ~]$ vim /tmp/Email-Ids <—–Put your email id list>

prabhat
[zimbra@kvit ~]$ vim /etc/create-user.sh

#! /bin/sh
while read NAME
do
zmprov ca $NAME@6987.in 1234567 <——-This is the default password for all users>
done < /etc/Email-Ids
[zimbra@kvit ~]$ /bin/sh /etc/create-user.sh

Senior Linux Administrator at KV IT-Solutions Pvt Ltd || A Linux Lover || having 4 years of experience || Handling various Linux projects || Email ID : prabhat@kvit.in || cell: 9818001497

“We are born free, No gates and Windows can snatch our freedom “

Download PDF

NO COMMENTS

Leave a Reply

Required Captcha *