Refine search
throw new SendFailedException("No recipient addresses"); throw new SendFailedException("No recipient addresses"); Session.getDefaultInstance(System.getProperties(), null); Transport transport; if ((transport = s.getTransport(protaddresses[0])) == null) { Address[] a = sex.getInvalidAddresses(); if (a != null) for (int j = 0; j < a.length; j++) a = sex.getValidSentAddresses(); if (a != null) for (int k = 0; k < a.length; k++) Address[] c = sex.getValidUnsentAddresses(); if (c != null) for (int l = 0; l < c.length; l++) invalid.toArray(c); throw new SendFailedException("Sending failed", chainedEx, a, b, c);
Session session = Session.getInstance( props ); session.setDebug( log.isDebug() ); throw new MessagingException( BaseMessages.getString( PKG, "JobMail.Error.ReplyEmailNotFilled" ) ); transport = session.getTransport( protocol ); String authPass = getPassword( authenticationPassword ); transport.connect( environmentSubstitute( Const.NVL( server, "" ) ), Integer.parseInt( environmentSubstitute( Const.NVL( port, "" ) ) ), transport.connect(); SendFailedException sfex = (SendFailedException) ex; Address[] invalid = sfex.getInvalidAddresses(); if ( invalid != null ) { logError( " ** Invalid Addresses" ); Address[] validUnsent = sfex.getValidUnsentAddresses(); if ( validUnsent != null ) { logError( " ** ValidUnsent Addresses" ); Address[] validSent = sfex.getValidSentAddresses(); if ( validSent != null ) {
t = session.getTransport(); } catch (final MessagingException fail) { throw attach(protocol, fail); t.sendMessage(abort, all); t.close(); } catch (final MessagingException ME) { closed = ME; Address[] recip = sfe.getInvalidAddresses(); if (recip != null && recip.length != 0) { setErrorContent(abort, verify, sfe); recip = sfe.getValidSentAddresses(); if (recip != null && recip.length != 0) { reportUnexpectedSend(abort, verify, sfe); new MessagingException(msg, IOE); setErrorContent(abort, verify, ME); reportError(abort, ME, ErrorManager.OPEN_FAILURE); MessagingException ME = new MessagingException(msg, IOE); setErrorContent(abort, verify, ME); reportError(abort, ME, ErrorManager.OPEN_FAILURE);
session = Session.getInstance(props); boolean debug = EntityUtilProperties.propertyValueEqualsIgnoreCase("general", "mail.debug.on", "Y", delegator); session.setDebug(debug); trans = session.getTransport("smtp"); if (!useSmtpAuth) { trans.connect(); } else { trans.connect(sendVia, authUser, authPass); trans.sendMessage(mail, mail.getAllRecipients()); results.put("messageWrapper", new MimeMessageWrapper(session, mail)); results.put("messageId", mail.getMessageID()); List<SMTPAddressFailedException> failedAddresses = new LinkedList<>(); Exception nestedException = null; while ((nestedException = e.getNextException()) != null && nestedException instanceof MessagingException) { if (nestedException instanceof SMTPAddressFailedException) { SMTPAddressFailedException safe = (SMTPAddressFailedException) nestedException;
properties.setProperty("mail.smtp.auth", "true"); Session session = Session.getInstance(properties); MimeMessage msg = new MimeMessage(session); transport.sendMessage(msg, msg.getAllRecipients()); } catch (MessagingException mex) { Exception ex = mex; strError.append("Caught " + mex.getClass().getName() + "\n"); strError.append("Message: " + mex.getMessage() + "\n\n"); do { if (ex instanceof SendFailedException) { SendFailedException sfex = (SendFailedException) ex; Address[] invalid = sfex.getInvalidAddresses(); if (invalid != null) { strError.append("** Invalid Addresses\n"); Address[] validUnsent = sfex.getValidUnsentAddresses(); if (validUnsent != null) { strError.append(" ** ValidUnsent Addresses\n"); Address[] validSent = sfex.getValidSentAddresses(); if (validSent != null) { strError.append(" ** ValidSent Addresses\n");
Transport transport = session.getTransport(allRecipients[0]); while (true) { try { transport.connect(); transport.sendMessage(msg, allRecipients); break; } catch (SendFailedException e) { if (e.getNextException() != null && (e.getNextException() instanceof SocketException || e.getNextException() instanceof ConnectException)) { context.getListener().getLogger().println("Socket error sending email, retrying once more in 10 seconds..."); transport.close(); Thread.sleep(10000); } else { Address[] addresses = e.getValidSentAddresses(); if (addresses != null && addresses.length > 0) { buf = new StringBuilder("Successfully sent to the following addresses:"); addresses = e.getValidUnsentAddresses(); if (addresses != null && addresses.length > 0) { buf = new StringBuilder("Error sending to the following VALID addresses:"); addresses = e.getInvalidAddresses(); if (addresses != null && addresses.length > 0) { buf = new StringBuilder("Error sending to the following INVALID addresses:"); debug(context.getListener().getLogger(), "SendFailedException message: " + e.getMessage()); break;
MailSendException aExceptionToBeRemembered = null; try (final Transport aTransport = m_aSession.getTransport (m_bSMTPS ? SMTPS_PROTOCOL : SMTP_PROTOCOL)) aTransport.addConnectionListener (aConnectionListener); aTransport.connect (m_aSMTPSettings.getHostName (), m_aSMTPSettings.getPort (), m_aSMTPSettings.getUserName (), aTransport.sendMessage (aMimeMessage, aMimeMessage.getAllRecipients ()); throw new IllegalStateException ("Never expected to come beyong sendMessage!"); final ICommonsSet <String> aValidSent = CollectionHelper.newSetMapped (ex.getValidSentAddresses (), Address::toString); final ICommonsSet <String> aValidUnsent = CollectionHelper.newSetMapped (ex.getValidUnsentAddresses (), Address::toString); final ICommonsSet <String> aInvalid = CollectionHelper.newSetMapped (ex.getInvalidAddresses (), Address::toString); Exception ex2; MessagingException bex = ex; while ((ex2 = bex.getNextException ()) != null && ex2 instanceof MessagingException) if (WebExceptionHelper.isServerNotReachableConnection (ex.getCause ())) aExceptionToBeRemembered = new MailSendException ("Failed to connect to mail server: " + ex.getCause ().getMessage ());
throw new MessagingException("SMTP can only send RFC822 messages"); throw new MessagingException(addresses[i] + " is not an InternetAddress"); throw new SendFailedException("No recipient addresses"); use8bit = ((SMTPMessage)message).getAllow8bitMIME(); if (!use8bit) use8bit = PropUtil.getBooleanProperty(session.getProperties(), "mail." + name + ".allow8bitmime", false); if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "MessagingException while sending", mex); if (mex.getNextException() instanceof IOException) {
private void sendEmail(Message message) throws MessagingException { try { Transport.send(message); } catch (NoSuchProviderException se) { LOG.error("Could not find an SMTP transport provider to email", se); throw se; } catch (MessagingException me) { LOG.error("Message Exception in transporting SLA alert email", me); if (me instanceof SendFailedException) { Address[] invalidAddrs = ((SendFailedException) me).getInvalidAddresses(); if (invalidAddrs != null && invalidAddrs.length > 0) { for (Address addr : invalidAddrs) { try { // 'get' method loads key into cache when it doesn't exist AtomicInteger val = blackList.get(addr.toString()); val.incrementAndGet(); } catch (Exception e) { LOG.debug("blacklist loading threw exception: " + e.getMessage()); } } } } throw me; } }
while (true) { try { Transport.send(msg); break; } catch (SendFailedException e) { if (e.getNextException() != null && ((e.getNextException() instanceof SocketException) || (e.getNextException() instanceof ConnectException))) { Address[] addresses = e.getValidSentAddresses(); printToConsoleIfSuccess(listener, addresses); addresses = e.getValidUnsentAddresses(); if (addresses != null && addresses.length > 0) { buf = new StringBuilder("Error sending to the following VALID addresses:"); addresses = e.getInvalidAddresses(); if (addresses != null && addresses.length > 0) { buf = new StringBuilder("Error sending to the following INVALID addresses:"); debug(listener.getLogger(), "SendFailedException message: " + e.getMessage()); break;
@Override public void send(String fromAddress, String[] toAddresses, String subject, String body) { String joinedToAddresses = Joiner.on(",").join(toAddresses); LOGGER.info("sending SMTP email from: \"%s\", to: \"%s\", subject: \"%s\"", fromAddress, joinedToAddresses, subject); LOGGER.debug("sending SMTP email body:%n%s", body); try { MimeMessage mimeMessage = new MimeMessage(getSession()); mimeMessage.setFrom(InternetAddress.parse(fromAddress)[0]); mimeMessage.setSubject(subject, CHARSET); if (body.startsWith("<html>")) { Multipart multipart = new MimeMultipart(); MimeBodyPart html = new MimeBodyPart(); String contentType = "text/html; charset=" + CHARSET; html.setHeader("Content-Type", contentType); html.setContent(body, contentType); multipart.addBodyPart(html); mimeMessage.setContent(multipart); } else { mimeMessage.setText(body, CHARSET); } mimeMessage.setSentDate(new Date()); mimeMessage.setRecipients(Message.RecipientType.TO, InternetAddress.parse(joinedToAddresses)); Transport.send(mimeMessage); } catch (SendFailedException me) { throw new VisalloException("Error sending emails to: " + Joiner.on(",").join(me.getValidUnsentAddresses(), me.getInvalidAddresses()), me); } catch (MessagingException me) { throw new VisalloException("exception while sending email", me); } }
boolean bFailedToSome = false; SendFailedException sendex = new SendFailedException("Unable to send message to some recipients"); transport.sendMessage(message, remainingAddresses); } catch(SendFailedException ex) { bFailedToSome=true; sendex.setNextException(ex); remainingAddresses=ex.getValidUnsentAddresses(); transport.close();
boolean bFailedToSome = false; SendFailedException sendex = new SendFailedException("Unable to send message to some recipients"); Transport.send(message, remainingAddresses); } catch (SendFailedException ex) { bFailedToSome = true; sendex.setNextException(ex); remainingAddresses = ex.getValidUnsentAddresses();
message.setRecipients(Message.RecipientType.CC, ccRecipients); Transport.send(message); if (ex.getValidUnsentAddresses() != null) { List<Address> newRecips = new ArrayList<Address>(); List<Address> newCCs = new ArrayList<Address>(); for (Address validUnsent : ex.getValidUnsentAddresses()) { for (Address recip : recipients) { if (validUnsent.equals(recip)) { message.setRecipients(Message.RecipientType.CC, new Address[0]); Transport.send(message);
sendPartial = ((SMTPMessage)message).getSendPartial(); if (!sendPartial) sendPartial = PropUtil.getBooleanProperty(session.getProperties(), "mail." + name + ".sendpartial", false); if (sendPartial) notify = ((SMTPMessage)message).getDSNNotify(); if (notify == null) notify = session.getProperty("mail." + name + ".dsn.notify"); mex = sfex; else mex.setNextException(sfex); break; mex = sfex; else mex.setNextException(sfex); break; mex = sfex; else mex.setNextException(sfex); break; throw new SendFailedException("Invalid Addresses", mex, validSentAddr, validUnsentAddr, invalidAddr);
if (debug) out.println("DEBUG SMTP: Can only send RFC822 msgs"); throw new MessagingException("SMTP can only send RFC822 messages"); throw new MessagingException(addresses[i] + " is not an InternetAddress"); throw new SendFailedException("No recipient addresses"); if (debug) { out.println("DEBUG SMTP: MessagingException while sending"); mex.printStackTrace(out);
statusMsg = "The system was unable to deliver your mail. Please try again later. [SEND FAILED]"; outFile.println( statusMsg ); outFile.println( e.getMessage() ); } catch (MessagingException e) { statusMsg = "The system was unable to deliver your mail. Please try again later. [MESSAGING]"; outFile.println( statusMsg ); outFile.println( e.getMessage() ); e.printStackTrace();
sendPartial = ((SMTPMessage)message).getSendPartial(); if (!sendPartial) { String sp = session.getProperty("mail." + name + ".sendpartial"); sendPartial = sp != null && sp.equalsIgnoreCase("true"); notify = ((SMTPMessage)message).getDSNNotify(); if (notify == null) notify = session.getProperty("mail." + name + ".dsn.notify"); mex = sfex; else mex.setNextException(sfex); break; mex = sfex; else mex.setNextException(sfex); break; mex = sfex; else mex.setNextException(sfex); break; throw new SendFailedException("Invalid Addresses", mex, validSentAddr, validUnsentAddr, invalidAddr);
transport.sendMessage(aMessage, aMessage.getAllRecipients()); message._deliverySucceeded(); if (debug) _stats.incrementErrorCount(); NSArray<String> invalidEmails = ERMailUtils.convertInternetAddressesToNSArray(e.getInvalidAddresses()); notifyInvalidEmails(invalidEmails); message._invalidRecipients(invalidEmails);
throw new MessagingException("SMTP can only send RFC822 messages"); throw new MessagingException(addresses[i] + " is not an InternetAddress"); throw new SendFailedException("No recipient addresses"); logger.log(Level.FINE, "MessagingException while sending", mex); if (mex.getNextException() instanceof IOException) {