List of usage examples for javax.mail MessagingException getMessage
public String getMessage()
From source file:org.apache.axis2.transport.mail.SimpleMailListener.java
private String getMailHeader(MimeMessage msg, String headerName) throws AxisFault { try {/*from ww w . j a v a 2s .c o m*/ String values[] = msg.getHeader(headerName); if (values != null) { return parseHeaderForQuotes(values[0]); } else { return null; } } catch (MessagingException e) { throw new AxisFault(e.getMessage(), e); } }
From source file:org.apache.axis2.transport.mail.SimpleMailListener.java
private String getMailHeaderFromPart(Part part, String headerName) throws AxisFault { try {/*w w w .j a v a 2s. c o m*/ String values[] = part.getHeader(headerName); if (values != null) { return parseHeaderForQuotes(values[0]); } else { return null; } } catch (MessagingException e) { throw new AxisFault(e.getMessage(), e); } }
From source file:dk.qabi.imapfs.IMAPFileSystem.java
public void rename(String from, String to) throws FuseException { IMAPEntry src = findEntry(from);/*from www . java 2s . c om*/ IMAPEntry srcdir = findEntry(PathUtil.extractParent(from)); IMAPEntry destdir = findEntry(PathUtil.extractParent(to)); if (src == null) { log.warn("Source does not exist"); throw new FuseException("Source does not exist").initErrno(FuseException.EACCES); } if (!(srcdir instanceof IMAPDirectory)) { log.warn("Source is not an existing directory"); throw new FuseException("Source is not an existing directory").initErrno(FuseException.EACCES); } if (!(destdir instanceof IMAPDirectory)) { log.warn("Destination is not an existing directory"); throw new FuseException("Destination is not an existing directory").initErrno(FuseException.EACCES); } try { if (src instanceof IMAPDirectory) { ((IMAPDirectory) src).renameTo(to); } else { final IMAPFile file = (IMAPFile) src; if (!srcdir.equals(destdir)) { file.moveTo((IMAPDirectory) destdir); } final String destName = PathUtil.extractName(to); if (!destName.equals(file.getName())) { file.rename(destName); } } } catch (MessagingException e) { log.error("Error renaming", e); throw new FuseException("Error renaming: " + e.getMessage()).initErrno(FuseException.EACCES); } }
From source file:at.molindo.notify.channel.mail.DirectMailClient.java
@Override protected String toErrorMessage(MessagingException e) { if (e instanceof SendFailedException) { if (e.getNextException() instanceof SMTPSendFailedException) { final SMTPSendFailedException se = (SMTPSendFailedException) e.getNextException(); return se.getCommand() + " failed " + " with " + se.getReturnCode() + " (" + e.getMessage() + ")"; } else if (e.getNextException() instanceof SMTPAddressFailedException) { // copied from above, as there is no common base class but same // methods final SMTPAddressFailedException se = (SMTPAddressFailedException) e.getNextException(); return se.getCommand() + " failed " + " with " + se.getReturnCode() + " (" + e.getMessage() + ")"; } else {/* w ww .jav a 2s. c o m*/ final StringBuilder buf = new StringBuilder(); Address[] addresses = ((SendFailedException) e).getInvalidAddresses(); if (addresses != null) { for (final Address a : addresses) { buf.append(a).append(" "); } } return "invalied address(es): " + buf + "(" + ExceptionUtils.getAllMessages(e) + ")"; } } else { return super.toErrorMessage(e); } }
From source file:dk.qabi.imapfs.IMAPFileSystem.java
private IMAPEntry findEntry(String path) throws FuseException { IMAPEntry entry;// w w w . j a va 2s . c om if (path == null) { entry = null; } else { if ("/".equals(path)) entry = rootEntry; else try { entry = rootEntry.get(path.substring(1)); } catch (MessagingException e) { log.error("Error finding entry", e); throw new FuseException("Error finding entry: " + e.getMessage()) .initErrno(FuseException.ENOENT); } } if (entry == null) { log.debug("Path '" + path + "' not found"); throw new FuseException("Path '" + path + "' not found").initErrno(FuseException.ENOENT); } return entry; }
From source file:dk.qabi.imapfs.IMAPFileSystem.java
/** * Return an array with entries to the content the directory passed as a parameter *//* w w w. j a va 2 s. com*/ public FuseDirEnt[] getdir(String absolutePath) throws FuseException { FuseDirEnt[] dirEntries; IMAPDirectory dir = (IMAPDirectory) findEntry(absolutePath); if (dir.isDirectory()) { IMAPEntry[] children; try { children = dir.getChildren(true); } catch (MessagingException e) { log.error("Error getting children", e); throw new FuseException("Error getting children: " + e.getMessage()) .initErrno(FuseException.ENOENT); } dirEntries = new FuseDirEnt[children.length]; for (int i = 0; i < children.length; i++) { IMAPEntry child = children[i]; dirEntries[i] = new FuseDirEnt(); dirEntries[i].name = child.getName(); dirEntries[i].mode = child.isDirectory() ? FuseFtype.TYPE_DIR : FuseFtype.TYPE_FILE; } } else { dirEntries = new FuseDirEnt[0]; } return dirEntries; }
From source file:se.vgregion.userfeedback.impl.FeedbackReportServiceImpl.java
private void sendReportByEmail(UserFeedback report, String subject) throws MessagingException { String reportEmail = report.getCaseBackend().getMbox(); if (reportEmail != null && !"".equals(reportEmail)) { String description = makeReport(EMAIL_TEMPLATE, report); String[] reportEmailArray = { reportEmail }; try {// w w w.ja va 2 s. co m emailService.postMailWithAttachments(reportEmailArray, subject, description, FEEDBACK_REPORT_SERVICE_NOREPLY, mapAttachments(report)); } catch (MessagingException e1) { LOGGER.error("Email submission failed:", e1); String[] emailTo = { FEEDBACK_REPORT_SERVICE_ADMIN_EMAIL }; emailService.postMailWithAttachments(emailTo, FEEDBACK_REPORT_ERROR_EMAIL_SUBJECT, "" + e1.getMessage() + "\n" + description, FEEDBACK_REPORT_SERVICE_NOREPLY, mapAttachments(report)); } } }
From source file:com.cubusmail.mail.imap.IMAPMailFolder.java
public int getUnreadMessageCount() { try {/* w w w .j a v a 2s . co m*/ return this.folder.getUnreadMessageCount(); } catch (MessagingException ex) { logger.error(ex.getMessage(), ex); return 0; } }
From source file:com.zimbra.cs.mailclient.smtp.SmtpTransportTest.java
@Test(timeout = 3000) public void noAuthMechansims() throws Exception { server = MockTcpServer.scenario().sendLine("220 test ready").recvLine() // EHLO .sendLine("250-OK").sendLine("250 AUTH NTLM").build().start(PORT); Session session = JMSession.getSession(); Transport transport = session.getTransport("smtp"); try {/*from w w w.j a va2 s . c om*/ transport.connect("localhost", PORT, "zimbra", "secret"); Assert.fail(); } catch (MessagingException e) { Assert.assertEquals("No auth mechanism supported: [NTLM]", e.getMessage()); } server.shutdown(1000); }
From source file:com.zimbra.cs.mailclient.smtp.SmtpTransportTest.java
@Test(timeout = 3000) public void noAuth() throws Exception { server = MockTcpServer.scenario().sendLine("220 test ready").recvLine() // EHLO .sendLine("250 OK").build().start(PORT); Session session = JMSession.getSession(); Transport transport = session.getTransport("smtp"); try {/*from w ww .ja v a 2s . c om*/ transport.connect("localhost", PORT, "zimbra", "secret"); Assert.fail(); } catch (MessagingException e) { Assert.assertEquals("The server doesn't support SMTP-AUTH.", e.getMessage()); } server.shutdown(1000); }