How to set smarthost(smtpauth) in zimbra

How to set smarthost(smtpauth) in zimbra

by -
0 3956

How to set smarthost(smtpauth) in zimbra

[[email protected] conf]$ su – zimbra

[[email protected] conf]$ cp /opt/zimbra/conf/zmconfigd.cf /opt/zimbra/conf/zmconfigd.cf.org

Note: Remove all bleow lines from zmconfigd.cf

[[email protected] 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

[[email protected] conf]$ vim /opt/zimbra/postfix/conf/bysender

@kvit.in mail.kvit.in

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

[[email protected] conf]$ postmap /opt/zimbra/conf/relay_password
[[email protected] 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
[[email protected] ~]$ zmprov ms “kvit.in” -zimbraServiceEnabled antivirus
[[email protected] ~]$ zmprov ms “kvit.in” -zimbraServiceEnabled antispam
[[email protected] ~]$ zmcontrol stop
[[email protected] ~]$ zmcontrol start
[[email protected] ~]$ zmprov ms “kvit.in” +zimbraServiceEnabled antivirus
[[email protected] ~]$ zmprov ms “kvit.in” +zimbraServiceEnabled antispam
[[email protected] ~]$ zmcontrol stop
[[email protected] ~]$ zmcontrol start

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

How to route mail through other server(Transport)

su – zimbra

[[email protected] conf]$ echo mail.6987.in [email protected]:[email protected] > /opt/zimbra/conf/relay_password
[[email protected] 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

[[email protected] 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.

[[email protected] 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
[[email protected] ~]$ vi /opt/zimbra/postfix/conf/transportfile

yahoo.com :[mail.6987.in]

[[email protected] ~]$ postmap /opt/zimbra/postfix/conf/transportfile
[[email protected] ~]$ zmlocalconfig -e postfix_transport_maps=”hash:/opt/zimbra/postfix/conf/transportfile proxy:ldap:/opt/zimbra/conf/ldap-transport.cf”
[[email protected] ~]$ 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
[[email protected] ~]$

How to make blacklist and whitelist in zimbra

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

[[email protected] ~]$ postmap /opt/zimbra/postfix/conf/transportfile

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

[[email protected] ~]$ 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
[[email protected] ~]$

B.  Through amavis

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

[[email protected] ~]# su – zimbra
[[email protected] ~]$ 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’);

[[email protected] ~]$ exit

[[email protected] ~]# touch /opt/zimbra/{whitelist,blacklist,spamlovers}
[[email protected] ~]# chown zimbra:zimbra /opt/zimbra/{whitelist,blacklist,spamlovers}

[[email protected] ~]# su – zimbra
[[email protected] ~]$ zmamavisdctl restart

[[email protected] ~]$ zmamavisdctl restart
Stopping amavisd… done.
Starting amavisd…done.
[[email protected] ~]$

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

[email protected]
xyz.com

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

Note: 0= disable

[[email protected] conf]$ zmprov gcf zimbraMessageIdDedupeCacheSize
zimbraMessageIdDedupeCacheSize: 3000

[[email protected] conf]$ zmprov mcf zimbraMessageIdDedupeCacheSize 0
[[email protected] conf]$ zmmailboxdctl restart
Stopping mailboxd…done.
Starting mailboxd…done.
[[email protected] conf]$ exit

Change logo path in zimbra

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

Change users loginURL https to http in zimbra 8.X

[[email protected] ~]$ zmtlsctl http
Setting ldap config zimbraMailMode http for kvit.in…done.
Rewriting config files for cyrus-sasl, webxml and mailboxd…done.
[[email protected] ~]$ 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
[[email protected] ~]$

How to check mailbox size in zimbra

[[email protected] ~]$ zmmailbox -z -m [email protected] gms
14.45 KB


Note:- Script for all users mailbox size.

[[email protected] ~]$ 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

[[email protected] ~]$ /bin/sh /opt/zimbra/backup/checkmailsize.sh

Mailbox size of [email protected] = 0 B
Mailbox size of [email protected] = 88.73 KB
Mailbox size of [email protected] = 0 B
Mailbox size of [email protected] = 0 B
Mailbox size of [email protected] = 0 B
Mailbox size of [email protected] = 0 B
Mailbox size of [email protected] = 14.45 KB
Mailbox size of [email protected] = 0 B

How to do empty inbox of a user in zimbra

[[email protected] ~]$ zmmailbox -z -m [email protected] 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

[[email protected] ~]$ zmmailbox -z -m [email protected] 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

[[email protected] ~]$ zmprov gaa | grep mydomain.com$ > /tmp/temp_file

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

[

[email protected] ~]$ 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

[[email protected] ~]$ /bin/ sh /opt/zimbra/backup/script.sh

# Remove temp_file 

[[email protected] ~]$ rm -f /tmp/temp_file

How to restric particuler mailid or domain through transport

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

 

[[email protected] ~]$ vim /opt/zimbra/conf/postfix_transport

[email protected] error: Forbidden Recipient Address
gmail.com error:On this domain mails are not allowed

[[email protected] ~]$ postmap /opt/zimbra/conf/postfix_transport
[[email protected] ~]$ 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>

[[email protected] ~]$ zmmtactl restart

How to remove mail subject base in zimbra.

Note:-  There are two method.
A:-

[[email protected] ~]$ vim /opt/zimbra/backup/rm_message.sh

#!/bin/bash
# rm_message.sh [email protected] subject
if [ -z “$2” ]; then
echo “usage: rm_message.sh [email protected] 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

[[email protected] ~]$ /bin/sh /opt/zimbra/backup/rm_message.sh [email protected] “Email From IRCTC”

 

B:-

[[email protected] conf]$ zmmailbox -z -m “[email protected]” 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

[[email protected] conf]$ zmmailbox -z -m [email protected] dm 281,262

Note:– From all users

[[email protected] ~]$ 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
[[email protected] ~]$ /bin/sh /opt/zimbra/backup/hi.sh

How to set RBL lines from cli.

[[email protected] ~]$ vim /opt/zimbra/conf/zmconfigd/smtpd_recipient_restrictions.cf

%%contains VAR:zimbraServiceEnabled cbpolicyd, check_policy_service inet:localhost:@@[email protected]@%%
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

 

[[email protected] ~]$ 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

[[email protected] ~]$ zmmailbox -z -m [email protected] getRestURL “//?fmt=tgz” > /tmp/[email protected]

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

[[email protected] ~]$ zmmailbox -z -m [email protected] postRestURL “//?fmt=tgz&resolve=reset” /tmp/ [email protected]

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

[[email protected] ~]$ zmprov ga [email protected] 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:

[[email protected] ~]$ SIEVEVAR=`cat /tmp/prabhat.rule`


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

[[email protected] ~]$ zmprov ma [email protected] zimbraMailSieveScript “$SIEVEVAR”

How to add catchall in zimbra

[[email protected] ~]$ zmprov modifyAccount [email protected] zimbraMailCatchAllAddress @kvit.in

:- Now all mails will go in [email protected]

How to bypass RBL listed IP in Zimbra

[[email protected] ~]# su – zimbra

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

[[email protected] ~]$ 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
[[email protected] ~]$ vi /opt/zimbra/conf/allow_rbl

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

How to add maildir formate mails in zimbra

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

[[email protected] ~]$ zmmailbox -z -m [email protected] addMessage “/inbox” /home/narendra/maildir/cur

How to increase brifcase size and mail sending size

Note:- 150000000 bytes; = 150M

[[email protected] ~]$ zmprov modifyConfig zimbraFileUploadMaxSize 150000000
[[email protected] ~]$ zmprov modifyConfig zimbraMtaMaxMessageSize 150000000

How to Check allowed networks in zimbra

[[email protected] ~]$ 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

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

How to enable Disclaimer in zimbra

[[email protected] ~]$ zmprov mcf zimbraDomainMandatoryMailSignatureEnabled TRUE

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

 

#add disclaimer per domain wise

[[email protected] ~]$ 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

[[email protected] ~]$ zmamavisdctl restart

How to add bulk users in zimbra

Note:Change in the script as you required.

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

prabhat
[[email protected] ~]$ vim /etc/create-user.sh

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

Download PDF

CEO, KV IT-Solutions Pvt. Ltd. | [email protected] | 9810028374|
Linux Professional and an Industrial Trainer | 20 + years Experience in IT Industry

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

SIMILAR ARTICLES

0 1573

0 1205

0 1101

NO COMMENTS

Leave a Reply