]> code.citadel.org Git - citadel.git/commitdiff
serv_smtp.c: when sending out mail, try EHLO first, then HELO
authorArt Cancro <ajc@citadel.org>
Thu, 6 Apr 2006 20:27:06 +0000 (20:27 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 6 Apr 2006 20:27:06 +0000 (20:27 +0000)
citadel/serv_smtp.c

index 0aac60fc326b582f71c35901e1cef58c5283a885..a91aa6788843950b7348919218f95b8823bbc6d9 100644 (file)
@@ -1080,8 +1080,8 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        /* At this point we know we are talking to a real SMTP server */
 
-       /* Do a HELO command */
-       snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn);
+       /* Do a EHLO command.  If it fails, try the HELO command. */
+       snprintf(buf, sizeof buf, "EHLO %s\r\n", config.c_fqdn);
        lprintf(CTDL_DEBUG, ">%s", buf);
        sock_write(sock, buf, strlen(buf));
        if (ml_sock_gets(sock, buf) < 0) {
@@ -1090,6 +1090,16 @@ void smtp_try(const char *key, const char *addr, int *status,
                goto bail;
        }
        lprintf(CTDL_DEBUG, "<%s\n", buf);
+       if (buf[0] != '2') {
+               snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn);
+               lprintf(CTDL_DEBUG, ">%s", buf);
+               sock_write(sock, buf, strlen(buf));
+               if (ml_sock_gets(sock, buf) < 0) {
+                       *status = 4;
+                       strcpy(dsn, "Connection broken during SMTP HELO");
+                       goto bail;
+               }
+       }
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;