Browse Source

Modified Deliver_SMTP to use HTTP_HOST in SMTP HELO commands.
If HTTP_HOST is not set, fall back to original SquirrelMail behavior. (Use $domain)
Should close #560524 (SMTP DNS resolution)

tassium 22 years ago
parent
commit
289f91b1c1
2 changed files with 14 additions and 4 deletions
  1. 2 0
      ChangeLog
  2. 12 4
      class/deliver/Deliver_SMTP.class.php

+ 2 - 0
ChangeLog

@@ -26,6 +26,8 @@ Version 1.4.0 RC 2
   - Move login_form hook to be actually in the login form.
   - Fix message_details plugin ability to save a raw message.
   - Try better to get the filename of an attachment.
+  - Deliver_SMTP class now uses HTTP_HOST in SMTP HELO.  Should fix DNS
+    issues some people have reported. (Closes #560524)
 	
 Version 1.4.0 RC 1
 ------------------

+ 12 - 4
class/deliver/Deliver_SMTP.class.php

@@ -49,11 +49,19 @@ class Deliver_SMTP extends Deliver {
 	if ($this->errorCheck($tmp, $stream)) {
     	    return(0);
 	}
-    
+
+	/* If $_SERVER['HTTP_HOST'] is set, use that in our HELO to the SMTP
+	   server.  This should fix the DNS issues some people have had */
+	if (sqgetGlobalVar('HTTP_HOST', $HTTP_HOST, SQ_SERVER)) { // HTTP_HOST is set
+		$helohost = $HTTP_HOST;
+	} else { // For some reason, HTTP_HOST is not set - revert to old behavior
+		$helohost = $domain;
+	}
+	
 	/* Lets introduce ourselves */
 	if (( $smtp_auth_mech == 'cram-md5') or ( $smtp_auth_mech == 'digest-md5' )) {
 	  // Doing some form of non-plain auth
-	  fputs($stream, "EHLO $domain\r\n");
+	  fputs($stream, "EHLO $helohost\r\n");
 	  $tmp = fgets($stream,1024);
 	  if ($this->errorCheck($tmp,$stream)) {
 	    return(0);
@@ -99,14 +107,14 @@ class Deliver_SMTP extends Deliver {
     // CRAM-MD5 and DIGEST-MD5 code ends here
 	} elseif ($smtp_auth_mech == 'none') {
 	  // No auth at all, just send helo and then send the mail
-	  fputs($stream, "HELO $domain\r\n");
+	  fputs($stream, "HELO $helohost\r\n");
       $tmp = fgets($stream, 1024);
 	  if ($this->errorCheck($tmp, $stream)) {
         return(0);
 	  }
 	} elseif ($smtp_auth_mech == 'login') {
 	  // The LOGIN method
-      fputs($stream, "EHLO $domain\r\n");
+      fputs($stream, "EHLO $helohost\r\n");
       $tmp = fgets($stream, 1024);
 	  if ($this->errorCheck($tmp, $stream)) {
     	return(0);