From a820ac9dc88f67eed1a9d9bac551e91d1c6b7d96 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Wed, 20 May 2009 20:59:44 +0000 Subject: [PATCH] When sending an address literal to an SMTP EHLO command, do it with the right syntax 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 | 5 +++++ src/configtest.php | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/class/deliver/Deliver_SMTP.class.php b/class/deliver/Deliver_SMTP.class.php index 38ff412a..279b82cc 100644 --- a/class/deliver/Deliver_SMTP.class.php +++ b/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 diff --git a/src/configtest.php b/src/configtest.php index 2d45eb46..261ed2f8 100644 --- a/src/configtest.php +++ b/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; -- 2.25.1