summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorFlorian Zschocke <florian.zschocke@cycos.com>2014-11-18 23:53:33 +0100
committerFlorian Zschocke <florian.zschocke@cycos.com>2016-10-27 23:52:13 +0200
commit4218f97ed40240c28d57ae8cb4f9e521d8a65ad3 (patch)
treee6ead2936b1aefe3b3d789dabd8a3619e864fbf9 /src/main
parentd10fe0d8fd614f6ae6606179b0326bdc6a5f6af8 (diff)
downloadgitblit-4218f97ed40240c28d57ae8cb4f9e521d8a65ad3.tar.gz
gitblit-4218f97ed40240c28d57ae8cb4f9e521d8a65ad3.zip
Improve logging when sending email fails.merged-logSendFailedException
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/gitblit/service/MailService.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/service/MailService.java b/src/main/java/com/gitblit/service/MailService.java
index ec3a84ca..58acc9c0 100644
--- a/src/main/java/com/gitblit/service/MailService.java
+++ b/src/main/java/com/gitblit/service/MailService.java
@@ -17,6 +17,7 @@ package com.gitblit.service;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Properties;
@@ -31,6 +32,7 @@ import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
+import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
@@ -272,9 +274,22 @@ public class MailService implements Runnable {
while ((message = queue.poll()) != null) {
try {
if (settings.getBoolean(Keys.mail.debug, false)) {
- logger.info("send: " + StringUtils.trimString(message.getSubject(), 60));
+ logger.info("send: '" + StringUtils.trimString(message.getSubject(), 60)
+ + "' to:" + StringUtils.trimString(Arrays.toString(message.getAllRecipients()), 300));
}
Transport.send(message);
+ } catch (SendFailedException sfe) {
+ if (settings.getBoolean(Keys.mail.debug, false)) {
+ logger.error("Failed to send message: {}", sfe.getMessage());
+ logger.info(" Invalid addresses: {}", Arrays.toString(sfe.getInvalidAddresses()));
+ logger.info(" Valid sent addresses: {}", Arrays.toString(sfe.getValidSentAddresses()));
+ logger.info(" Valid unset addresses: {}", Arrays.toString(sfe.getValidUnsentAddresses()));
+ logger.info("", sfe);
+ }
+ else {
+ logger.error("Failed to send message: {}", sfe.getMessage(), sfe.getNextException());
+ }
+ failures.add(message);
} catch (Throwable e) {
logger.error("Failed to send message", e);
failures.add(message);