Anchor the regexp. Thanks Thijs Kinkhorst.
[squirrelmail.git] / src / configtest.php
index 2d45eb4640b5a54c637e5ef68b611315a9bc9653..030acf2daa641f4f0b2b2d138096aa28ba7cdbdf 100644 (file)
@@ -622,8 +622,17 @@ if($useSendmail) {
     if ($use_smtp_tls===2) {
         // if something breaks, script should close smtp connection on exit.
 
+
+        // format EHLO argument correctly if needed
+        //
+        if (preg_match('/^\d+\.\d+\.\d+\.\d+$/', $client_ip))
+            $helohost = '[' . $client_ip . ']';
+        else // some day might add IPv6 here
+            $helohost = $client_ip;
+
+
         // say helo
-        fwrite($stream,"EHLO $client_ip\r\n");
+        fwrite($stream,"EHLO $helohost\r\n");
 
         $ehlo=array();
         $ehlo_error = false;