When sending an address literal to an SMTP EHLO command, do it with the right syntax
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 20 May 2009 20:59:44 +0000 (20:59 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 20 May 2009 20:59:44 +0000 (20:59 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13728 7612ce4b-ef26-0410-bec9-ea0150e637f0

class/deliver/Deliver_SMTP.class.php
src/configtest.php

index 38ff412ac8ee2592b51fa36cb57502d4822939aa..279b82cc8204592603e99e5a7da5685e28b0ec06 100644 (file)
@@ -135,6 +135,11 @@ class Deliver_SMTP extends Deliver {
             $helohost = $domain;
         }
 
+        // if the host is an IPv4 address, enclose it in brackets
+        //
+        if (preg_match('/\d+\.\d+\.\d+\.\d+/', $helohost))
+            $helohost = '[' . $helohost . ']';
+
         /* Lets introduce ourselves */
         fputs($stream, "EHLO $helohost\r\n");
         // Read ehlo response
index 2d45eb4640b5a54c637e5ef68b611315a9bc9653..261ed2f874d1e63a4e546998060241b0a398c7a5 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;