From b2d67de8a9cf7e97fb592742e57c0dae249e65b2 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Mon, 2 Oct 2006 19:51:27 +0000 Subject: [PATCH] Reissue EHLO after successful STARTTLS. --- ChangeLog | 3 ++ src/net/smtp/SMTPTransport.cpp | 72 +++++++++++++++++++------------- vmime/net/smtp/SMTPTransport.hpp | 1 + 3 files changed, 46 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b4a4b94..e1f40eb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ VERSION 0.8.1cvs 2006-10-02 Vincent Richard + * SMTPTransport.cpp: reissue EHLO command after a successful STARTTLS + negociation. + * word, wordEncoder: fixed bug #1096610 which caused encoding of a non-integral number of characters (and then, generation of incorrectly-formed words) with multi-bytes charsets. diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp index 98a2c9ee..07da0e4c 100644 --- a/src/net/smtp/SMTPTransport.cpp +++ b/src/net/smtp/SMTPTransport.cpp @@ -135,36 +135,7 @@ void SMTPTransport::connect() } // Identification - // First, try Extended SMTP (ESMTP) - // - // eg: C: EHLO thismachine.ourdomain.com - // S: 250-smtp.theserver.com - // S: 250 AUTH CRAM-MD5 DIGEST-MD5 - - sendRequest("EHLO " + platformDependant::getHandler()->getHostName()); - - if ((resp = readResponse())->getCode() != 250) - { - // Next, try "Basic" SMTP - // - // eg: C: HELO thismachine.ourdomain.com - // S: 250 OK - - sendRequest("HELO " + platformDependant::getHandler()->getHostName()); - - if ((resp = readResponse())->getCode() != 250) - { - internalDisconnect(); - throw exceptions::connection_greeting_error(resp->getLastLine().getText()); - } - - m_extendedSMTP = false; - } - else - { - m_extendedSMTP = true; - m_extendedSMTPResponse = resp->getText(); - } + helo(); #if VMIME_HAVE_TLS_SUPPORT // Setup secured connection, if requested @@ -196,6 +167,9 @@ void SMTPTransport::connect() { throw; } + + // Must reissue a EHLO command [RFC-2487, 5.2] + helo(); } #endif // VMIME_HAVE_TLS_SUPPORT @@ -207,6 +181,44 @@ void SMTPTransport::connect() } +void SMTPTransport::helo() +{ + // First, try Extended SMTP (ESMTP) + // + // eg: C: EHLO thismachine.ourdomain.com + // S: 250-smtp.theserver.com + // S: 250 AUTH CRAM-MD5 DIGEST-MD5 + + sendRequest("EHLO " + platformDependant::getHandler()->getHostName()); + + ref resp; + + if ((resp = readResponse())->getCode() != 250) + { + // Next, try "Basic" SMTP + // + // eg: C: HELO thismachine.ourdomain.com + // S: 250 OK + + sendRequest("HELO " + platformDependant::getHandler()->getHostName()); + + if ((resp = readResponse())->getCode() != 250) + { + internalDisconnect(); + throw exceptions::connection_greeting_error(resp->getLastLine().getText()); + } + + m_extendedSMTP = false; + m_extendedSMTPResponse.clear(); + } + else + { + m_extendedSMTP = true; + m_extendedSMTPResponse = resp->getText(); + } +} + + void SMTPTransport::authenticate() { if (!m_extendedSMTP) diff --git a/vmime/net/smtp/SMTPTransport.hpp b/vmime/net/smtp/SMTPTransport.hpp index 592660a8..90a3e2c2 100644 --- a/vmime/net/smtp/SMTPTransport.hpp +++ b/vmime/net/smtp/SMTPTransport.hpp @@ -75,6 +75,7 @@ private: void internalDisconnect(); + void helo(); void authenticate(); #if VMIME_HAVE_SASL_SUPPORT void authenticateSASL();