From 9e975191869650cda027563a6af1dfd51ff7656c Mon Sep 17 00:00:00 2001 From: Jan Osusky Date: Fri, 20 Oct 2017 13:48:19 +0200 Subject: [PATCH 1/2] Fix of compilation warning reported by GCC 4.9.3 'class vmime::net::messageSetEnumerator' has virtual functions and accessible non-virtual destructor --- src/vmime/net/messageSet.cpp | 5 +++++ src/vmime/net/messageSet.hpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vmime/net/messageSet.cpp b/src/vmime/net/messageSet.cpp index e30ebc5c..0b3ea961 100644 --- a/src/vmime/net/messageSet.cpp +++ b/src/vmime/net/messageSet.cpp @@ -37,6 +37,11 @@ namespace vmime { namespace net { +// messageSetEnumerator + +messageSetEnumerator::~messageSetEnumerator() +{ +} // messageRange diff --git a/src/vmime/net/messageSet.hpp b/src/vmime/net/messageSet.hpp index 1be49761..9d6ca4f4 100644 --- a/src/vmime/net/messageSet.hpp +++ b/src/vmime/net/messageSet.hpp @@ -50,7 +50,7 @@ class UIDMessageRange; class VMIME_EXPORT messageSetEnumerator { public: - + virtual ~messageSetEnumerator(); virtual void enumerateNumberMessageRange(const numberMessageRange& range) = 0; virtual void enumerateUIDMessageRange(const UIDMessageRange& range) = 0; }; From 6cfe2c5f6cf1fa5c07c361bc6a5ec5b9690b68c7 Mon Sep 17 00:00:00 2001 From: Jan Osusky Date: Fri, 20 Oct 2017 14:05:01 +0200 Subject: [PATCH 2/2] Add SMTPS with AUTH PLAIN without SASL GNU SASL is a nice library but comes with its own prerequisites and dependencies. As IMAP and POP3 are able to work without SASL it seems to me logical to add some authentication support to SMTP too. As these days most of the communication is encrypted it is common to use simple mechanism like AUTH PLAIN, so I have added it. --- src/vmime/net/smtp/SMTPConnection.cpp | 38 ++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/vmime/net/smtp/SMTPConnection.cpp b/src/vmime/net/smtp/SMTPConnection.cpp index 3785126a..8709efe4 100644 --- a/src/vmime/net/smtp/SMTPConnection.cpp +++ b/src/vmime/net/smtp/SMTPConnection.cpp @@ -40,6 +40,10 @@ #if VMIME_HAVE_SASL_SUPPORT #include "vmime/security/sasl/SASLContext.hpp" +#else + #include "vmime/utility/encoder/b64Encoder.hpp" + #include "vmime/utility/inputStreamStringAdapter.hpp" + #include "vmime/utility/outputStreamStringAdapter.hpp" #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT @@ -48,7 +52,6 @@ #endif // VMIME_HAVE_TLS_SUPPORT - // Helpers for service properties #define GET_PROPERTY(type, prop) \ (m_transport.lock()->getInfos().getPropertyValue (getSession(), \ @@ -307,6 +310,39 @@ void SMTPConnection::authenticate() throw; } } +#else // no SASL + + // allow AUTH PLAIN over TLS - it is a popular and simple mechanism + if (m_secured) + { + std::vector authMechs; + hasExtension("AUTH", &authMechs); + + if (authMechs.empty()) + throw exceptions::authentication_error("No AUTH mechanism available."); + + const string plain("PLAIN"); + if (std::find(authMechs.begin(), authMechs.end(), plain) != authMechs.end()) + { + const string username = getAuthenticator()->getUsername(); + const string password = getAuthenticator()->getPassword(); + const string authToken = username + '\0' + username + '\0' + password; + auto encoder = new vmime::utility::encoder::b64Encoder(); + utility::inputStreamStringAdapter in(authToken); + string authTokenBase64; + utility::outputStreamStringAdapter out(authTokenBase64); + encoder->encode(in, out); + sendRequest(SMTPCommand::AUTH(plain, authTokenBase64)); + shared_ptr response = readResponse(); + const int code = response ? response->getCode() : -1; + if (code == 235) + { + m_authenticated = true; + return; + } + } + } + #endif // VMIME_HAVE_SASL_SUPPORT // No other authentication method is possible