diff --git a/mailnews/compose/public/nsISmtpServer.idl b/mailnews/compose/public/nsISmtpServer.idl index 5c801d352647..44d3cfa2d9a4 100644 --- a/mailnews/compose/public/nsISmtpServer.idl +++ b/mailnews/compose/public/nsISmtpServer.idl @@ -37,6 +37,7 @@ interface nsISmtpServer : nsISupports { attribute string redirectorType; attribute long authMethod; + readonly attribute boolean trySecAuth; attribute long trySSL; readonly attribute string serverURI; diff --git a/mailnews/compose/src/nsSmtpProtocol.cpp b/mailnews/compose/src/nsSmtpProtocol.cpp index 24cc1a1459ae..15755a37c159 100644 --- a/mailnews/compose/src/nsSmtpProtocol.cpp +++ b/mailnews/compose/src/nsSmtpProtocol.cpp @@ -247,6 +247,7 @@ void nsSmtpProtocol::Initialize(nsIURI * aURL) m_prefAuthMethod = PREF_AUTH_NONE; m_usernamePrompted = PR_FALSE; m_prefTrySSL = PREF_SSL_TRY; + m_prefTrySecAuth = PR_TRUE; m_tlsInitiated = PR_FALSE; m_urlErrorState = NS_ERROR_FAILURE; @@ -294,6 +295,7 @@ void nsSmtpProtocol::Initialize(nsIURI * aURL) if (smtpServer) { smtpServer->GetAuthMethod(&m_prefAuthMethod); smtpServer->GetTrySSL(&m_prefTrySSL); + smtpServer->GetTrySecAuth(&m_prefTrySecAuth); } rv = RequestOverrideInfo(smtpServer); @@ -686,6 +688,8 @@ PRInt32 nsSmtpProtocol::SendEhloResponse(nsIInputStream * inputStream, PRUint32 if (m_responseText.Find("EXTERNAL", PR_TRUE, 5) >= 0) SetFlag(SMTP_AUTH_EXTERNAL_ENABLED); + if(m_prefTrySecAuth) + { if (m_responseText.Find("CRAM-MD5", PR_TRUE, 5) >= 0) { nsresult rv; @@ -693,6 +697,7 @@ PRInt32 nsSmtpProtocol::SendEhloResponse(nsIInputStream * inputStream, PRUint32 // this checks if psm is installed... if (NS_SUCCEEDED(rv)) SetFlag(SMTP_AUTH_CRAM_MD5_ENABLED); + } } // for use after mechs disabled fallbacks when login failed diff --git a/mailnews/compose/src/nsSmtpProtocol.h b/mailnews/compose/src/nsSmtpProtocol.h index 08db9b12f87a..99fcb1576a5c 100644 --- a/mailnews/compose/src/nsSmtpProtocol.h +++ b/mailnews/compose/src/nsSmtpProtocol.h @@ -177,6 +177,7 @@ private: // *** the following should move to the smtp server when we support // multiple smtp servers PRInt32 m_prefAuthMethod; + PRBool m_prefTrySecAuth; PRBool m_usernamePrompted; PRInt32 m_prefTrySSL; PRBool m_tlsEnabled; diff --git a/mailnews/compose/src/nsSmtpServer.cpp b/mailnews/compose/src/nsSmtpServer.cpp index 2ad61a016bd6..8a76084377ca 100644 --- a/mailnews/compose/src/nsSmtpServer.cpp +++ b/mailnews/compose/src/nsSmtpServer.cpp @@ -217,6 +217,22 @@ nsSmtpServer::SetTrySSL(PRInt32 trySSL) return prefs->SetIntPref(pref.get(), trySSL); } +NS_IMETHODIMP +nsSmtpServer::GetTrySecAuth(PRBool *trySecAuth) +{ + nsresult rv; + nsCAutoString pref; + NS_ENSURE_ARG_POINTER(trySecAuth); + nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); + if (NS_FAILED(rv)) return rv; + *trySecAuth = PR_TRUE; + getPrefString("trySecAuth", pref); + rv = prefs->GetBoolPref(pref.get(), trySecAuth); + if (NS_FAILED(rv)) + prefs->GetBoolPref("mail.smtpserver.default.trySecAuth", trySecAuth); + return NS_OK; +} + NS_IMETHODIMP nsSmtpServer::GetAuthMethod(PRInt32 *authMethod) { diff --git a/mailnews/mailnews.js b/mailnews/mailnews.js index 591478d69a6f..34630db9e9bf 100644 --- a/mailnews/mailnews.js +++ b/mailnews/mailnews.js @@ -383,6 +383,7 @@ pref("mail.server.default.manualMark",false); pref("mail.server.default.manualMarkMode",0); // 0 == "move to junk folder", 1 == "delete" pref("mail.smtpserver.default.auth_method", 1); // auth any +pref("mail.smtpserver.default.trySecAuth", true); pref("mail.smtpserver.default.try_ssl", 0); // For the next 3 prefs, see diff --git a/modules/libpref/src/init/mailnews.js b/modules/libpref/src/init/mailnews.js index 591478d69a6f..34630db9e9bf 100644 --- a/modules/libpref/src/init/mailnews.js +++ b/modules/libpref/src/init/mailnews.js @@ -383,6 +383,7 @@ pref("mail.server.default.manualMark",false); pref("mail.server.default.manualMarkMode",0); // 0 == "move to junk folder", 1 == "delete" pref("mail.smtpserver.default.auth_method", 1); // auth any +pref("mail.smtpserver.default.trySecAuth", true); pref("mail.smtpserver.default.try_ssl", 0); // For the next 3 prefs, see