فهرست منبع

When sending an address literal to an SMTP EHLO command, do it with the right syntax

pdontthink 16 سال پیش
والد
کامیت
ef75b59bbb
2فایلهای تغییر یافته به همراه15 افزوده شده و 1 حذف شده
  1. 5 0
      class/deliver/Deliver_SMTP.class.php
  2. 10 1
      src/configtest.php

+ 5 - 0
class/deliver/Deliver_SMTP.class.php

@@ -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

+ 10 - 1
src/configtest.php

@@ -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;