diff options
author | Magnus Bäck <baeck@google.com> | 2013-01-17 12:34:34 -0500 |
---|---|---|
committer | Edwin Kempin <edwin.kempin@sap.com> | 2013-01-23 09:45:13 +0100 |
commit | f83d1b65e51d0b0382db0bb37f7981f99979e4da (patch) | |
tree | c900cf02a5bcf953a48421ba0c6dc2135ae8787a | |
parent | 328c9f7833ad8c1a3c38ce844ef31b693cc44a4f (diff) |
Improve SMTP client error messages
Change the wording of a couple of the error messages in the SMTP client
to make it more clear at exactly what stage in the SMTP transaction the
server returned an error, and always include the server's response text.
Also, make sure already rejected recipients are included in the error
message when the server rejects the DATA command. Otherwise there's no
way of debugging rejected recipients if all recipients are rejected
since that typically results in a DATA command rejection. Because some
SMTP servers (e.g. Postfix with the default configuration) delay
rejection of HELO/EHLO and MAIL FROM commands to the RCPT TO stage,
this can happen not only for bad recipients.
Change-Id: I4cdd5f18563b038dc724346d79cb77e1dc3aa4c1
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/mail/SmtpEmailSender.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/SmtpEmailSender.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/SmtpEmailSender.java index f6817102bc..ce45ffe763 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/SmtpEmailSender.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/SmtpEmailSender.java @@ -182,7 +182,12 @@ public class SmtpEmailSender implements EmailSender { Writer w = client.sendMessageData(); if (w == null) { - throw new EmailException("Server " + smtpHost + " rejected body"); + /* Include rejected recipient error messages here to not lose that + * information. That piece of the puzzle is vital if zero recipients + * are accepted and the server consequently rejects the DATA command. + */ + throw new EmailException(rejected + "Server " + smtpHost + + " rejected DATA command: " + client.getReplyString()); } w = new BufferedWriter(w); @@ -201,7 +206,8 @@ public class SmtpEmailSender implements EmailSender { w.close(); if (!client.completePendingCommand()) { - throw new EmailException("Server " + smtpHost + " rejected body"); + throw new EmailException("Server " + smtpHost + + " rejected message body: " + client.getReplyString()); } client.logout(); @@ -237,7 +243,8 @@ public class SmtpEmailSender implements EmailSender { } if (!client.login()) { String e = client.getReplyString(); - throw new EmailException("SMTP server rejected login: " + e); + throw new EmailException( + "SMTP server rejected HELO/EHLO greeting: " + e); } if (smtpEncryption == Encryption.TLS) { |