File tree Expand file tree Collapse file tree 4 files changed +40
-10
lines changed
Expand file tree Collapse file tree 4 files changed +40
-10
lines changed Original file line number Diff line number Diff line change 6565 get_user_ip
6666fi
6767
68- # Generating list of mail domains for HELO
69- ls /etc/exim4/domains > /etc/exim4/mailhelo.conf
70- sed -i " s \(.*\) \1:\1 " /etc/exim4/mailhelo.conf
71-
7268# Generating timestamp
7369new_timestamp
7470
@@ -105,6 +101,18 @@ if [[ "$MAIL_SYSTEM" =~ exim ]]; then
105101 echo " $local_ip " > $HOMEDIR /$user /conf/mail/$domain /ip
106102 fi
107103
104+ # Setting HELO for mail domain
105+ if [ ! -z " $local_ip " ]; then
106+ IP_RDNS=$( is_ip_rdns_valid " $local_ip " )
107+ if [ ! -z " $IP_RDNS " ]; then
108+ if [ $( grep -s " ^${domain} :" /etc/exim4/mailhelo.conf) ]; then
109+ sed -i " /^${domain} :/c\\ ${domain} :${IP_RDNS} " /etc/exim4/mailhelo.conf
110+ else
111+ echo ${domain} :${IP_RDNS} >> /etc/exim4/mailhelo.conf
112+ fi
113+ fi
114+ fi
115+
108116 # Adding antispam protection
109117 if [ " $antispam " = ' yes' ]; then
110118 touch $HOMEDIR /$user /conf/mail/$domain /antispam
Original file line number Diff line number Diff line change @@ -85,9 +85,8 @@ rm -f $USER_DATA/mail/$domain.pem
8585rm -f $USER_DATA /mail/$domain .pub
8686rm -f $USER_DATA /mail/* @$domain .msg
8787
88- # Generating list of mail domains for HELO
89- ls /etc/exim4/domains > /etc/exim4/mailhelo.conf
90- sed -i " s \(.*\) \1:\1 " /etc/exim4/mailhelo.conf
88+ # Unsetting HELO for mail domain
89+ sed -i " /^${domain} :/d" /etc/exim4/mailhelo.conf
9190
9291# Decreasing domain value
9392decrease_user_value " $user " ' $U_MAIL_DOMAINS'
Original file line number Diff line number Diff line change @@ -25,6 +25,18 @@ is_ip_key_empty() {
2525 fi
2626}
2727
28+ is_ip_rdns_valid () {
29+ ip=" $1 "
30+ network_ip=$( echo $ip | cut -d" ." -f1-3)
31+ awk_ip=$( echo $network_ip | sed ' s|\.|/\&\&/|g' )
32+ rev_awk_ip=$( echo $awk_ip | rev)
33+ rdns=$( dig +short -x $ip | sed ' s/.$//' )
34+
35+ if [ ! -z $rdns ] && [ ! $( echo $rdns | awk " /$awk_ip / || /$rev_awk_ip /" ) ]; then
36+ echo $rdns
37+ fi
38+ }
39+
2840# Update ip address value
2941update_ip_value () {
3042 key=" $1 "
Original file line number Diff line number Diff line change @@ -502,9 +502,20 @@ rebuild_mail_domain_conf() {
502502 echo " $local_ip " > $HOMEDIR /$user /conf/mail/$domain /ip
503503 fi
504504
505- # Generating list of mail domains for HELO
506- ls /etc/exim4/domains > /etc/exim4/mailhelo.conf
507- sed -i " s \(.*\) \1:\1 " /etc/exim4/mailhelo.conf
505+
506+ # Setting HELO for mail domain
507+ if [ ! -z " $local_ip " ]; then
508+ IP_RDNS=$( is_ip_rdns_valid " $local_ip " )
509+ if [ ! -z " $IP_RDNS " ]; then
510+ if [ $( grep -s " ^${domain} :" /etc/exim4/mailhelo.conf) ]; then
511+ sed -i " /^${domain} :/c\\ ${domain} :${IP_RDNS} " /etc/exim4/mailhelo.conf
512+ else
513+ echo ${domain} :${IP_RDNS} >> /etc/exim4/mailhelo.conf
514+ fi
515+ else
516+ sed -i " /^${domain} :/d" /etc/exim4/mailhelo.conf
517+ fi
518+ fi
508519
509520 # Adding antispam protection
510521 if [ " $ANTISPAM " = ' yes' ]; then
You can’t perform that action at this time.
0 commit comments