@@ -110,36 +110,40 @@ function update($event_name, $data) {
110110 }
111111
112112 if ($ mail_config ['realtime_blackhole_list ' ] != $ old_ini_data ['mail ' ]['realtime_blackhole_list ' ]) {
113- $ rbl_updated = false ;
114- $ rbl_hosts = trim (preg_replace ('/\s+/ ' , '' , $ mail_config ['realtime_blackhole_list ' ]));
115- if ($ rbl_hosts != '' ){
116- $ rbl_hosts = explode (", " , $ rbl_hosts );
117- }
113+ # reject_rbl_client is now in smtpd_client_restrictions, remove here:
118114 $ options = preg_split ("/,\s*/ " , exec ("postconf -h smtpd_recipient_restrictions " ));
119115 $ new_options = array ();
120116 foreach ($ options as $ key => $ value ) {
121117 $ value = trim ($ value );
122118 if ($ value == '' ) continue ;
123- if (!preg_match ('/reject_rbl_client/ ' , $ value )) {
124- $ new_options [] = $ value ;
125- } else {
126- if (is_array ($ rbl_hosts ) && !empty ($ rbl_hosts ) && !$ rbl_updated ){
127- $ rbl_updated = true ;
128- foreach ($ rbl_hosts as $ key2 => $ value2 ) {
129- $ value2 = trim ($ value2 );
130- if ($ value2 != '' ) $ new_options [] = "reject_rbl_client " .$ value2 ;
131- }
132- }
133- }
119+ if (preg_match ('/^reject_rbl_client/ ' , $ value )) continue ;
120+ $ new_options [] = $ value ;
134121 }
135- //* first time add rbl-list
136- if (!$ rbl_updated && is_array ($ rbl_hosts ) && !empty ($ rbl_hosts )) {
122+ $ app ->system ->exec_safe ("postconf -e ? " , 'smtpd_recipient_restrictions = ' .implode (", " , $ new_options ));
123+
124+ $ rbl_options = array ();
125+ $ rbl_hosts = trim (preg_replace ('/\s+/ ' , '' , $ mail_config ['realtime_blackhole_list ' ]));
126+ if ($ rbl_hosts != '' ){
127+ $ rbl_hosts = explode (", " , $ rbl_hosts );
137128 foreach ($ rbl_hosts as $ key => $ value ) {
138129 $ value = trim ($ value );
139- if ($ value != '' ) $ new_options [] = "reject_rbl_client " .$ value ;
130+ if ($ value != '' ) $ rbl_options [] = "reject_rbl_client " .$ value ;
140131 }
141132 }
142- $ app ->system ->exec_safe ("postconf -e ? " , 'smtpd_recipient_restrictions = ' .implode (", " , $ new_options ));
133+
134+ $ options = preg_split ("/,\s*/ " , exec ("postconf -h smtpd_client_restrictions " ));
135+ $ new_options = array ();
136+ foreach ($ options as $ key => $ value ) {
137+ $ value = trim ($ value );
138+ if ($ value == '' ) continue ;
139+ if (preg_match ('/^reject_rbl_client/ ' , $ value )) continue ;
140+ $ new_options [] = $ value ;
141+ if (preg_match ('/^permit_mynetworks/ ' , $ value )) {
142+ $ new_options = array_merge ($ new_options , $ rbl_options );
143+ $ rbl_options = array (); // so we don't ever array_merge twice
144+ }
145+ }
146+ $ app ->system ->exec_safe ("postconf -e ? " , 'smtpd_client_restrictions = ' .implode (", " , $ new_options ));
143147 }
144148
145149 if ($ mail_config ['reject_sender_login_mismatch ' ] != $ old_ini_data ['mail ' ]['reject_sender_login_mismatch ' ]) {
0 commit comments