# HG changeset patch # User Gene Smith # Date 1540104435 14400 # Node ID ded30314a53cfd75d95db2e808f3a5fdc6b4fd62 # Parent a3740c3d2e50219fa20730acf1f528b2545db198 Bug 1497488: Don't just say "unknown error" when a Mozilla security error occurs when sending. r=jorgk Now show the string defined by the Mozilla platform when a SMTP send security error occurs. diff --git a/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties b/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties --- a/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties +++ b/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties @@ -23,16 +23,22 @@ errorSendingFromCommand=An error occurre errorSendingDataCommand=An Outgoing server (SMTP) error occurred while sending mail. The server responded: %s. ## LOCALIZATION NOTE (errorSendingMessage): argument %s is the Outgoing server (SMTP) response errorSendingMessage=An error occurred while sending mail. The mail server responded: %s. Please check the message and try again. postFailed=The message could not be posted because connecting to the news server failed. The server may be unavailable or is refusing connections. Please verify that your news server settings are correct and try again. errorQueuedDeliveryFailed=An error occurred while delivering the unsent messages. sendFailed=Sending of the message failed. +## LOCALIZATION NOTE (sendFailedUnexpected): argument %X is a hex error code value +sendFailedUnexpected=Failed due to unexpected error %X. No description is available. + +## LOCALIZATION NOTE (smtpSecurityIssue): argument %S is the Outgoing server (SMTP) response +smtpSecurityIssue=The configuration related to %S must be corrected. + ## LOCALIZATION NOTE (smtpServerError): argument %s is the Outgoing server (SMTP) response smtpServerError=An error occurred while sending mail: Outgoing server (SMTP) error. The server responded: %s. unableToSendLater=Sorry, we were unable to save your message for sending later. ## LOCALIZATION NOTE (communicationsError): argument %d is the error code communicationsError=A communications error occurred: %d. Please try again. dontShowAlert=THIS IS JUST A PLACEHOLDER. YOU SHOULD NEVER SEE THIS STRING. diff --git a/mailnews/compose/src/nsComposeStrings.cpp b/mailnews/compose/src/nsComposeStrings.cpp --- a/mailnews/compose/src/nsComposeStrings.cpp +++ b/mailnews/compose/src/nsComposeStrings.cpp @@ -34,18 +34,16 @@ const char* errorStringNameForErrorCode( case NS_ERROR_SENDING_DATA_COMMAND: return "errorSendingDataCommand"; case NS_ERROR_SENDING_MESSAGE: return "errorSendingMessage"; case NS_ERROR_POST_FAILED: return "postFailed"; case NS_ERROR_QUEUED_DELIVERY_FAILED: return "errorQueuedDeliveryFailed"; - case NS_ERROR_SEND_FAILED: - return "sendFailed"; case NS_ERROR_SMTP_SERVER_ERROR: return "smtpServerError"; case NS_MSG_UNABLE_TO_SEND_LATER: return "unableToSendLater"; case NS_ERROR_COMMUNICATIONS_ERROR: return "communicationsError"; case NS_ERROR_BUT_DONT_SHOW_ALERT: return "dontShowAlert"; @@ -103,16 +101,16 @@ const char* errorStringNameForErrorCode( return "smtpAuthFailure"; case NS_ERROR_SMTP_AUTH_GSSAPI: return "smtpAuthGssapi"; case NS_ERROR_SMTP_AUTH_MECH_NOT_SUPPORTED: return "smtpAuthMechNotSupported"; case NS_ERROR_SMTP_AUTH_NOT_SUPPORTED: return "smtpAuthenticationNotSupported"; case NS_ERROR_ILLEGAL_LOCALPART: - return "illegalLocalPart"; + return "errorIllegalLocalPart"; default: return "sendFailed"; } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif } diff --git a/mailnews/compose/src/nsComposeStrings.h b/mailnews/compose/src/nsComposeStrings.h --- a/mailnews/compose/src/nsComposeStrings.h +++ b/mailnews/compose/src/nsComposeStrings.h @@ -20,17 +20,16 @@ #define NS_MSG_NO_SENDER NS_MSG_GENERATE_FAILURE(12510) #define NS_MSG_NO_RECIPIENTS NS_MSG_GENERATE_FAILURE(12511) #define NS_MSG_ERROR_WRITING_FILE NS_MSG_GENERATE_FAILURE(12512) #define NS_ERROR_SENDING_FROM_COMMAND NS_MSG_GENERATE_FAILURE(12514) #define NS_ERROR_SENDING_DATA_COMMAND NS_MSG_GENERATE_FAILURE(12516) #define NS_ERROR_SENDING_MESSAGE NS_MSG_GENERATE_FAILURE(12517) #define NS_ERROR_POST_FAILED NS_MSG_GENERATE_FAILURE(12518) #define NS_ERROR_QUEUED_DELIVERY_FAILED NS_MSG_GENERATE_FAILURE(12519) -#define NS_ERROR_SEND_FAILED NS_MSG_GENERATE_FAILURE(12520) #define NS_ERROR_SMTP_SERVER_ERROR NS_MSG_GENERATE_FAILURE(12524) #define NS_MSG_UNABLE_TO_SEND_LATER NS_MSG_GENERATE_FAILURE(12525) #define NS_ERROR_COMMUNICATIONS_ERROR NS_MSG_GENERATE_FAILURE(12526) #define NS_ERROR_BUT_DONT_SHOW_ALERT NS_MSG_GENERATE_FAILURE(12527) #define NS_ERROR_TCP_READ_ERROR NS_MSG_GENERATE_FAILURE(12528) #define NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS NS_MSG_GENERATE_FAILURE(12529) #define NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY NS_MSG_GENERATE_FAILURE(12530) #define NS_ERROR_MIME_MPART_ATTACHMENT_ERROR NS_MSG_GENERATE_FAILURE(12531) diff --git a/mailnews/compose/src/nsMsgSend.cpp b/mailnews/compose/src/nsMsgSend.cpp --- a/mailnews/compose/src/nsMsgSend.cpp +++ b/mailnews/compose/src/nsMsgSend.cpp @@ -80,16 +80,17 @@ #include "mozilla/mailnews/MimeEncoder.h" #include "mozilla/mailnews/MimeHeaderParser.h" #include "mozilla/dom/HTMLImageElement.h" #include "nsIMutableArray.h" #include "nsIMsgFilterService.h" #include "nsIMsgProtocolInfo.h" #include "mozIDOMWindow.h" #include "mozilla/Preferences.h" +#include "nsINSSErrorsService.h" using namespace mozilla; using namespace mozilla::mailnews; static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); #define PREF_MAIL_SEND_STRUCT "mail.send_struct" #define PREF_MAIL_STRICTLY_MIME "mail.strictly_mime" @@ -3180,28 +3181,27 @@ NS_IMETHODIMP nsMsgComposeAndSend::SendD case NS_ERROR_UNKNOWN_PROXY_HOST: aExitCode = NS_ERROR_SMTP_SEND_FAILED_UNKNOWN_SERVER; break; case NS_ERROR_CONNECTION_REFUSED: case NS_ERROR_PROXY_CONNECTION_REFUSED: aExitCode = NS_ERROR_SMTP_SEND_FAILED_REFUSED; break; case NS_ERROR_NET_INTERRUPT: + case NS_ERROR_ABORT: aExitCode = NS_ERROR_SMTP_SEND_FAILED_INTERRUPTED; break; case NS_ERROR_NET_TIMEOUT: case NS_ERROR_NET_RESET: aExitCode = NS_ERROR_SMTP_SEND_FAILED_TIMEOUT; break; case NS_ERROR_SMTP_PASSWORD_UNDEFINED: // nothing to do, just keep the code break; default: - if (aExitCode != NS_ERROR_ABORT && !NS_IS_MSG_ERROR(aExitCode)) - aExitCode = NS_ERROR_SMTP_SEND_FAILED_UNKNOWN_REASON; break; } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif } DeliverAsMailExit(aUrl, aExitCode); } @@ -3541,34 +3541,64 @@ nsMsgComposeAndSend::DoDeliveryExitProce { // If we fail on the news delivery, no sense in going on so just notify // the user and exit. if (NS_FAILED(aExitCode)) { const char* exitString = errorStringNameForErrorCode(aExitCode); nsString eMsg; if (aExitCode == NS_ERROR_SMTP_SEND_FAILED_UNKNOWN_SERVER || - aExitCode == NS_ERROR_SMTP_SEND_FAILED_UNKNOWN_REASON || aExitCode == NS_ERROR_SMTP_SEND_FAILED_REFUSED || aExitCode == NS_ERROR_SMTP_SEND_FAILED_INTERRUPTED || aExitCode == NS_ERROR_SMTP_SEND_FAILED_TIMEOUT || aExitCode == NS_ERROR_SMTP_PASSWORD_UNDEFINED || aExitCode == NS_ERROR_SMTP_AUTH_FAILURE || aExitCode == NS_ERROR_SMTP_AUTH_GSSAPI || aExitCode == NS_ERROR_SMTP_AUTH_MECH_NOT_SUPPORTED || aExitCode == NS_ERROR_SMTP_AUTH_NOT_SUPPORTED || aExitCode == NS_ERROR_SMTP_AUTH_CHANGE_ENCRYPT_TO_PLAIN_NO_SSL || aExitCode == NS_ERROR_SMTP_AUTH_CHANGE_ENCRYPT_TO_PLAIN_SSL || aExitCode == NS_ERROR_SMTP_AUTH_CHANGE_PLAIN_TO_ENCRYPT || - aExitCode == NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS) { + aExitCode == NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS) + { + // Print basic SMTP error with the server name encoded. FormatStringWithSMTPHostNameByName(exitString, eMsg); - } else { - mComposeBundle->GetStringFromName(exitString, eMsg); } - + else + { + nsCOMPtr nsserr = do_GetService(NS_NSS_ERRORS_SERVICE_CONTRACTID); + if (nsserr && NS_SUCCEEDED(nsserr->GetErrorMessage(aExitCode, eMsg))) + { + // This is a server security issue as determined by the Mozilla platform. + // To the Mozilla security message string, appended a string having + // additional information with the server name encoded. + nsString securityMsg; + FormatStringWithSMTPHostNameByName("smtpSecurityIssue", securityMsg); + eMsg.Append('\n'); + eMsg.Append(securityMsg); + } + else if (PL_strcmp(exitString, "sendFailed")) + { + // Not the default string. A mailnews error occurred that does not + // require the server name to be encoded. Just print the descriptive + // string. + mComposeBundle->GetStringFromName(exitString, eMsg); + } + else + { + // Encode the error code in first string. Then append a supplemental + // string that encodes the server name. + nsString tmpStr; + mComposeBundle->GetStringFromName("sendFailedUnexpected", tmpStr); + nsTextFormatter::ssprintf(eMsg, tmpStr.get(), static_cast(aExitCode)); + FormatStringWithSMTPHostNameByName("smtpSendFailedUnknownReason", tmpStr); + eMsg.Append('\n'); + eMsg.Append(tmpStr); + } + } Fail(aExitCode, eMsg.get(), &aExitCode); NotifyListenerOnStopSending(nullptr, aExitCode, nullptr, nullptr); return; } if (aCheckForMail) { if ((mCompFields->GetTo() && *mCompFields->GetTo()) || diff --git a/mailnews/compose/src/nsMsgSendReport.cpp b/mailnews/compose/src/nsMsgSendReport.cpp --- a/mailnews/compose/src/nsMsgSendReport.cpp +++ b/mailnews/compose/src/nsMsgSendReport.cpp @@ -277,17 +277,16 @@ NS_IMETHODIMP nsMsgSendReport::DisplayRe #ifdef __GNUC__ // Temporary workaround until bug 783526 is fixed. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch" #endif switch (currError) { case NS_BINDING_ABORTED: - case NS_ERROR_SEND_FAILED: case NS_ERROR_SEND_FAILED_BUT_NNTP_OK: case NS_MSG_FAILED_COPY_OPERATION: case NS_MSG_UNABLE_TO_SEND_LATER: case NS_MSG_UNABLE_TO_SAVE_DRAFT: case NS_MSG_UNABLE_TO_SAVE_TEMPLATE: //Ignore, don't need to repeat ourself. break; default: diff --git a/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties b/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties --- a/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties +++ b/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties @@ -23,16 +23,22 @@ errorSendingFromCommand=An error occurre errorSendingDataCommand=An Outgoing server (SMTP) error occurred while sending mail. The server responded: %s. ## LOCALIZATION NOTE (errorSendingMessage): argument %s is the Outgoing server (SMTP) response errorSendingMessage=An error occurred while sending mail. The mail server responded: %s. Please check the message and try again. postFailed=The message could not be posted because connecting to the news server failed. The server may be unavailable or is refusing connections. Please verify that your news server settings are correct and try again. errorQueuedDeliveryFailed=An error occurred while delivering unsent messages. sendFailed=Sending of the message failed. +## LOCALIZATION NOTE (sendFailedUnexpected): argument %X is a hex error code value +sendFailedUnexpected=Failed due to unexpected error %X. No description is available. + +## LOCALIZATION NOTE (smtpSecurityIssue): argument %S is the Outgoing smtp server name +smtpSecurityIssue=The configuration related to %S must be corrected. + ## LOCALIZATION NOTE (smtpServerError): argument %s is the Outgoing server (SMTP) response smtpServerError=An error occurred while sending mail: Outgoing server (SMTP) error. The server responded: %s. unableToSendLater=Sorry, we were unable to save your message for sending later. ## LOCALIZATION NOTE (communicationsError): argument %d is the error code communicationsError=A communications error occurred: %d. Please try again. dontShowAlert=THIS IS JUST A PLACEHOLDER. YOU SHOULD NEVER SEE THIS STRING.