summaryrefslogtreecommitdiff
path: root/camel/providers/smtp
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-10-07 18:13:53 +0000
committerJeffrey Stedfast <fejj@src.gnome.org>2002-10-07 18:13:53 +0000
commitcb6225fad799cb89b0b231b5c913af7df407a815 (patch)
tree4e8ec1dc6543901d6968dbb0e891bb9408400620 /camel/providers/smtp
parent973a1c07e5050827da7b2aa387e74c1718edd82c (diff)
downloadevolution-data-server-cb6225fad799cb89b0b231b5c913af7df407a815.tar.gz
Fixes bug #31752
2002-10-07 Jeffrey Stedfast <fejj@ximian.com> Fixes bug #31752 * providers/smtp/camel-smtp-transport.c (connect_to_server): Don't forget to send another EHLO command to the server once we toggle into STARTTLS mode. (smtp_helo): Reset any flags set using the EHLO response and also any authtypes.
Diffstat (limited to 'camel/providers/smtp')
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c37
-rw-r--r--camel/providers/smtp/camel-smtp-transport.h2
2 files changed, 27 insertions, 12 deletions
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 8b84c2935..03e7d03bd 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -245,11 +245,7 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex)
return FALSE;
/* set some smtp transport defaults */
- transport->flags &= ~(CAMEL_SMTP_TRANSPORT_IS_ESMTP |
- CAMEL_SMTP_TRANSPORT_8BITMIME |
- CAMEL_SMTP_TRANSPORT_STARTTLS |
- CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES);
-
+ transport->flags &= CAMEL_SMTP_TRANSPORT_USE_SSL; /* reset all but ssl flags */
transport->authtypes = NULL;
port = service->url->port ? service->url->port : SMTP_PORT;
@@ -377,15 +373,22 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex)
} while (*(respbuf+3) == '-'); /* if we got "220-" then loop again */
/* Okay, now toggle SSL/TLS mode */
- ret = camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream));
- if (ret != -1)
- return TRUE;
+ if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Failed to connect to SMTP server %s in secure mode: %s"),
+ service->url->host, g_strerror (errno));
+ goto exception_cleanup;
+ }
+
+ /* We are supposed to re-EHLO after a successful STARTTLS to
+ re-fetch any supported extensions. */
+ if (!smtp_helo (transport, ex) && !transport->connected)
+ return FALSE;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to SMTP server %s in secure mode: %s"),
- service->url->host, g_strerror (errno));
+ return TRUE;
exception_cleanup:
+
camel_object_unref (CAMEL_OBJECT (transport->istream));
transport->istream = NULL;
camel_object_unref (CAMEL_OBJECT (transport->ostream));
@@ -863,6 +866,18 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
const char *token;
int af;
+ /* these are flags that we set, so unset them in case we
+ are being called a second time (ie, after a STARTTLS) */
+ transport->flags &= ~(CAMEL_SMTP_TRANSPORT_8BITMIME |
+ CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES |
+ CAMEL_SMTP_TRANSPORT_STARTTLS);
+
+ if (transport->authtypes) {
+ g_hash_table_foreach (transport->authtypes, authtypes_free, NULL);
+ g_hash_table_destroy (transport->authtypes);
+ transport->authtypes = NULL;
+ }
+
camel_operation_start_transient (NULL, _("SMTP Greeting"));
/* get the local host name */
diff --git a/camel/providers/smtp/camel-smtp-transport.h b/camel/providers/smtp/camel-smtp-transport.h
index 9874eb09c..ef15f2b07 100644
--- a/camel/providers/smtp/camel-smtp-transport.h
+++ b/camel/providers/smtp/camel-smtp-transport.h
@@ -30,7 +30,7 @@
#ifdef __cplusplus
extern "C" {
#pragma }
-#endif /* __cplusplus }*/
+#endif /* __cplusplus */
#include "camel-transport.h"