\r
import java.io.File;\r
import java.util.ArrayList;\r
+import java.util.Arrays;\r
import java.util.Date;\r
import java.util.List;\r
import java.util.Properties;\r
import javax.mail.Message;\r
import javax.mail.MessagingException;\r
import javax.mail.PasswordAuthentication;\r
+import javax.mail.SendFailedException;\r
import javax.mail.Session;\r
import javax.mail.Transport;\r
import javax.mail.internet.InternetAddress;\r
while ((message = queue.poll()) != null) {\r
try {\r
if (settings.getBoolean(Keys.mail.debug, false)) {\r
- logger.info("send: " + StringUtils.trimString(message.getSubject(), 60));\r
+ logger.info("send: '" + StringUtils.trimString(message.getSubject(), 60)\r
+ + "' to:" + StringUtils.trimString(Arrays.toString(message.getAllRecipients()), 300));\r
}\r
Transport.send(message);\r
+ } catch (SendFailedException sfe) {\r
+ if (settings.getBoolean(Keys.mail.debug, false)) {\r
+ logger.error("Failed to send message: {}", sfe.getMessage());\r
+ logger.info(" Invalid addresses: {}", Arrays.toString(sfe.getInvalidAddresses()));\r
+ logger.info(" Valid sent addresses: {}", Arrays.toString(sfe.getValidSentAddresses()));\r
+ logger.info(" Valid unset addresses: {}", Arrays.toString(sfe.getValidUnsentAddresses()));\r
+ logger.info("", sfe);\r
+ }\r
+ else {\r
+ logger.error("Failed to send message: {}", sfe.getMessage(), sfe.getNextException());\r
+ }\r
+ failures.add(message);\r
} catch (Throwable e) {\r
logger.error("Failed to send message", e);\r
failures.add(message);\r