Index: camel/providers/smtp/ChangeLog
===================================================================
--- camel/providers/smtp/ChangeLog	(revision 8308)
+++ camel/providers/smtp/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2007-12-21  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #504837
+
+	* camel-smtp-transport.c: (smtp_helo), (connect_to_server):
+	Do not ignore HELO failed message.
+
 2007-12-19  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #341579
Index: camel/providers/smtp/camel-smtp-transport.c
===================================================================
--- camel/providers/smtp/camel-smtp-transport.c	(revision 8308)
+++ camel/providers/smtp/camel-smtp-transport.c	(working copy)
@@ -80,7 +80,7 @@
 static GList *query_auth_types (CamelService *service, CamelException *ex);
 static char *get_name (CamelService *service, gboolean brief);
 
-static gboolean smtp_helo (CamelSmtpTransport *transport, CamelException *ex);
+static gboolean smtp_helo (CamelSmtpTransport *transport, CamelException *ex, gboolean can_disconnect);
 static gboolean smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex);
 static gboolean smtp_mail (CamelSmtpTransport *transport, const char *sender,
 			   gboolean has_8bit_parts, CamelException *ex);
@@ -301,14 +301,14 @@
 
 	/* Try sending EHLO */
 	transport->flags |= CAMEL_SMTP_TRANSPORT_IS_ESMTP;
-	if (!smtp_helo (transport, ex)) {
+	if (!smtp_helo (transport, ex, FALSE)) {
 		if (!transport->connected)
 			return FALSE;
 
 		/* Fall back to HELO */
 		camel_exception_clear (ex);
 		transport->flags &= ~CAMEL_SMTP_TRANSPORT_IS_ESMTP;
-		if (!smtp_helo (transport, ex) && !transport->connected)
+		if (!smtp_helo (transport, ex, TRUE) && !transport->connected)
 			return FALSE;
 	}
 
@@ -369,7 +369,7 @@
 
 	/* We are supposed to re-EHLO after a successful STARTTLS to
            re-fetch any supported extensions. */
-	if (!smtp_helo (transport, ex) && !transport->connected)
+	if (!smtp_helo (transport, ex, TRUE) && !transport->connected)
 		return FALSE;
 
 	return TRUE;
@@ -931,7 +931,7 @@
 }
 
 static gboolean
-smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
+smtp_helo (CamelSmtpTransport *transport, CamelException *ex, gboolean can_disconnect)
 {
 	char *name = NULL, *cmdbuf = NULL, *respbuf = NULL;
 	const char *token, *numeric = NULL;
@@ -996,6 +996,9 @@
 			camel_operation_end (NULL);
 			g_free (respbuf);
 
+			if (can_disconnect)
+				camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
+
 			return FALSE;
 		}
 
