fix 190775 patch by ch.ey@gmx.net, some error messages from smtp server not displayed to user, r=bienvenu, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2005-01-04 17:28:47 +00:00
parent faa8ecd75c
commit e244cb6252
4 changed files with 53 additions and 19 deletions

View File

@ -110,7 +110,7 @@
12523=Mail sent successfully
## @name NS_ERROR_SMTP_SERVER_ERROR
12524=An error occurred sending mail: SMTP server error. The server responded: %s Contact your mail administrator for assistance.
12524=An error occurred sending mail: SMTP server error. The server responded: %s\n Contact your mail administrator for assistance.
## @name NS_MSG_UNABLE_TO_SEND_LATER
12525=Unable to save your message in order to send it later.
@ -241,6 +241,15 @@ noIdentities=You don't have any email identities yet. Create one with the Accou
## @name NS_MSG_ERROR_DOING_FCC
12571=There was an error copying the message to the Sent folder. Retry?
## @name NS_ERROR_SMTP_GREETING
12572=An error occurred sending mail: The mail server sent an incorrect greeting: %s.
## @name NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS1
12573=An error occurred sending mail: Unable to connect to SMTP server %S via STARTTLS since he doesn't support EHLO. Please verify that your Mail/News account settings are correct and try again.
## @name NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS2
12574=An error occurred sending mail: Unable to connect to SMTP server %S via STARTTLS since he doesn't offer STARTTLS In EHLO reponse. Please verify that your Mail/News account settings are correct and try again.
## Strings use for the save message dialog shown when the user close a message compose window
saveDlogTitle=Save Message
saveDlogMessage=Message has not been sent. Do you want to save the message in the Drafts folder?

View File

@ -140,4 +140,9 @@ private:
#define NS_MSG_ERROR_ATTACHING_FILE NS_MSG_GENERATE_FAILURE(12570)
#define NS_MSG_ERROR_DOING_FCC NS_MSG_GENERATE_FAILURE(12571)
#define NS_ERROR_SMTP_GREETING NS_MSG_GENERATE_FAILURE(12572)
#define NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS1 NS_MSG_GENERATE_FAILURE(12573)
#define NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS2 NS_MSG_GENERATE_FAILURE(12574)
#endif /* _nsMsgComposeStringBundle_H_ */

View File

@ -3650,7 +3650,10 @@ nsMsgComposeAndSend::DoDeliveryExitProcessing(nsIURI * aUri, nsresult aExitCode,
#endif
nsXPIDLString eMsg;
if (aExitCode == NS_ERROR_SMTP_SEND_FAILED || aExitCode == NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER)
if (aExitCode == NS_ERROR_SMTP_SEND_FAILED ||
aExitCode == NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER ||
aExitCode == NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS1 ||
aExitCode == NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS2)
FormatStringWithSMTPHostNameByID(aExitCode, getter_Copies(eMsg));
else
mComposeBundle->GetStringByID(aExitCode, getter_Copies(eMsg));

View File

@ -125,7 +125,8 @@ nsresult nsExplainErrorDetails(nsISmtpUrl * aSmtpUrl, int code, ...)
case NS_ERROR_SENDING_FROM_COMMAND:
case NS_ERROR_SENDING_RCPT_COMMAND:
case NS_ERROR_SENDING_DATA_COMMAND:
case NS_ERROR_SENDING_MESSAGE:
case NS_ERROR_SENDING_MESSAGE:
case NS_ERROR_SMTP_GREETING:
smtpBundle->GetStringByID(code, getter_Copies(eMsg));
msg = nsTextFormatter::vsmprintf(eMsg, args);
break;
@ -449,7 +450,7 @@ PRInt32 nsSmtpProtocol::SmtpResponse(nsIInputStream * inputStream, PRUint32 leng
line = m_lineStreamBuffer->ReadNextLine(inputStream, ln, pauseForMoreData);
if(pauseForMoreData || !line)
if (pauseForMoreData || !line)
{
SetFlag(SMTP_PAUSE_FOR_READ); /* pause */
PR_Free(line);
@ -460,25 +461,30 @@ PRInt32 nsSmtpProtocol::SmtpResponse(nsIInputStream * inputStream, PRUint32 leng
PR_LOG(SMTPLogModule, PR_LOG_ALWAYS, ("SMTP Response: %s", line));
cont_char = ' '; /* default */
sscanf(line, "%d%c", &m_responseCode, &cont_char);
// sscanf() doesn't update m_responseCode if line doesn't start
// with a number. That can be dangerous. So be sure to set
// m_responseCode to 0 if no items read.
if (PR_sscanf(line, "%d%c", &m_responseCode, &cont_char) <= 0)
m_responseCode = 0;
if(m_continuationResponse == -1)
if (m_continuationResponse == -1)
{
if (cont_char == '-') /* begin continuation */
m_continuationResponse = m_responseCode;
if(PL_strlen(line) > 3)
m_responseText = line+4;
// display the whole message if no valid response code or
// message shorter than 4 chars
m_responseText = (m_responseCode >= 100 && PL_strlen(line) > 3) ? line + 4 : line;
}
else
{ /* have to continue */
{ /* have to continue */
if (m_continuationResponse == m_responseCode && cont_char == ' ')
m_continuationResponse = -1; /* ended */
if (m_responseText.CharAt(m_responseText.Length() - 1) != '\n')
m_responseText += "\n";
if(PL_strlen(line) > 3)
m_responseText += line+4;
m_responseText += (PL_strlen(line) > 3) ? line + 4 : line;
}
if (m_responseCode == 220 && m_responseText.Length() && !m_tlsInitiated)
@ -486,7 +492,7 @@ PRInt32 nsSmtpProtocol::SmtpResponse(nsIInputStream * inputStream, PRUint32 leng
m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
}
if(m_continuationResponse == -1) /* all done with this response? */
if (m_continuationResponse == -1) /* all done with this response? */
{
m_nextState = m_nextStateAfterResponse;
ClearFlag(SMTP_PAUSE_FOR_READ); /* don't pause */
@ -501,9 +507,17 @@ PRInt32 nsSmtpProtocol::ExtensionLoginResponse(nsIInputStream * inputStream, PRU
PRInt32 status = 0;
nsCAutoString buffer("EHLO ");
if(m_responseCode != 220)
if (m_responseCode != 220)
{
m_urlErrorState = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER;
#ifdef DEBUG
nsresult rv =
#endif
nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_GREETING,
m_responseText.get());
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
return(NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER);
}
@ -640,7 +654,7 @@ PRInt32 nsSmtpProtocol::SendEhloResponse(nsIInputStream * inputStream, PRUint32
if (m_prefTrySSL == PREF_SECURE_ALWAYS_STARTTLS)
{
m_nextState = SMTP_ERROR_DONE;
m_urlErrorState = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER;
m_urlErrorState = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS1;
return(NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER);
}
@ -736,8 +750,11 @@ PRInt32 nsSmtpProtocol::SendEhloResponse(nsIInputStream * inputStream, PRUint32
if(TestFlag(SMTP_EHLO_SIZE_ENABLED) &&
m_sizelimit > 0 && (PRInt32)m_totalMessageSize > m_sizelimit)
{
nsresult rv = nsExplainErrorDetails(m_runningURL,
NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_1, m_sizelimit);
#ifdef DEBUG
nsresult rv =
#endif
nsExplainErrorDetails(m_runningURL,
NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_1, m_sizelimit);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
@ -821,7 +838,7 @@ PRInt32 nsSmtpProtocol::ProcessAuth()
else if (m_prefTrySSL == PREF_SECURE_ALWAYS_STARTTLS)
{
m_nextState = SMTP_ERROR_DONE;
m_urlErrorState = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER;
m_urlErrorState = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER_WITH_STARTTLS2;
return(NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER);
}
}