Package javax.mail

Examples of javax.mail.SendFailedException


  public void sendMessage (Message oMsg,
                           Address[] aAdrFrom, Address[] aAdrReply,
                           Address[] aAdrTo, Address[] aAdrCc, Address[] aAdrBcc)
    throws NoSuchProviderException,SendFailedException,ParseException,
           MessagingException,NullPointerException {
             SendFailedException s = null;
            
    if (DebugFile.trace) {
      DebugFile.writeln("Begin SessionHandler.sendMessage([Message],Address[],Address[],Address[],Address[],Address[])");
      DebugFile.incIdent();
      if (aAdrFrom!=null)
View Full Code Here


        // First collect all the addresses together.
        Address[] remainingAddresses = message.getAllRecipients();
        int nAddresses = remainingAddresses.length;
        boolean bFailedToSome = false;
       
        SendFailedException sendex = new SendFailedException("Unable to send message to some recipients");
       
        Transport transport = mailProvider.getTransport();
       
        // Try to send while there remain some potentially good addresses
        try {
            do {
                // Avoid a loop if we are stuck
                nAddresses = remainingAddresses.length;

                try {
                    // Send to the list of remaining addresses, ignoring the addresses attached to the message
                    transport.send(message, remainingAddresses);
                } catch(SendFailedException ex) {
                    bFailedToSome=true;
                    sendex.setNextException(ex);

                    // Extract the remaining potentially good addresses
                    remainingAddresses=ex.getValidUnsentAddresses();
                }
            } while (remainingAddresses!=null && remainingAddresses.length>0 && remainingAddresses.length!=nAddresses);
View Full Code Here

        // First collect all the addresses together.
        Address[] remainingAddresses = message.getAllRecipients();
        int nAddresses = remainingAddresses.length;
        boolean bFailedToSome = false;
       
        SendFailedException sendex = new SendFailedException("Unable to send message to some recipients");
       
        Transport transport = mailProvider.getTransport();
       
        // Try to send while there remain some potentially good addresses
        try {
            do {
                // Avoid a loop if we are stuck
                nAddresses = remainingAddresses.length;

                try {
                    // Send to the list of remaining addresses, ignoring the addresses attached to the message
                    transport.sendMessage(message, remainingAddresses);
                } catch(SendFailedException ex) {
                    bFailedToSome=true;
                    sendex.setNextException(ex);

                    // Extract the remaining potentially good addresses
                    remainingAddresses=ex.getValidUnsentAddresses();
                }
            } while (remainingAddresses!=null && remainingAddresses.length>0 && remainingAddresses.length!=nAddresses);
View Full Code Here

    // First collect all the addresses together.
        Address[] remainingAddresses = message.getAllRecipients();
        int nAddresses = remainingAddresses.length;
        boolean bFailedToSome = false;
       
        SendFailedException sendex = new SendFailedException("Unable to send message to some recipients");
       
    // Try to send while there remain some potentially good addresses
    do
        {
      // Avoid a loop if we are stuck
      nAddresses = remainingAddresses.length;

      try
      {
        // Send to the list of remaining addresses, ignoring the addresses attached to the message
            Transport.send(message,remainingAddresses);
      }
      catch(SendFailedException ex)
      {
        bFailedToSome=true;
        sendex.setNextException(ex);
       
        // Extract the remaining potentially good addresses
        remainingAddresses=ex.getValidUnsentAddresses();
      }
        } while (remainingAddresses!=null && remainingAddresses.length>0 && remainingAddresses.length!=nAddresses);
View Full Code Here

      }
    } catch (IOException e) {
      notifyTransportListeners(
          TransportEvent.MESSAGE_NOT_DELIVERED, new Address[0], addresses,
          new Address[0], message);
      throw new SendFailedException("MailService IO failed", e);
    } catch (IllegalArgumentException e) {
      throw new MessagingException("Illegal Arguments", e);
    }

    notifyTransportListeners(
View Full Code Here

                    }
                }
            } else {
                warning("Got Exception : " + e);
            }
            throw new SendFailedException("Error sending email", e);
        }
    }
View Full Code Here

                sendEmail( getFrom(), sCopiedMsg );
            }
           
        } catch (NoSuchProviderException ex) {
            warning("Got NoSuchProviderException.", ex);
            throw new SendFailedException("Error email, incorrect library provider.", ex);
        } catch (AuthenticationFailedException ex) {
            warning("Got AuthenticationFailedException.", ex);
            throw new SendFailedException("Error email, incorrect authentication." , ex);
        } catch (MessagingException ex) {
            warning("Got MessagingException.", ex);
            throw new SendFailedException("Error email, messaging parameters." , ex);
        } catch (Exception ex) {
            warning("Got Exception.", ex);
            throw new SendFailedException("Fail to process email.", ex);
        } finally {
            close();
        }
    }
View Full Code Here

                    }
                }
            } else {
                warning("Got Exception : " + e);
            }
            throw new SendFailedException("Error sending email", e);
        }
    }
View Full Code Here

                sendEmail( getFrom(), sCopiedMsg );
            }
           
        } catch (NoSuchProviderException ex) {
            warning("Got NoSuchProviderException.", ex);
            throw new SendFailedException("Error email, incorrect library provider.", ex);
        } catch (AuthenticationFailedException ex) {
            warning("Got AuthenticationFailedException.", ex);
            throw new SendFailedException("Error email, incorrect authentication." , ex);
        } catch (MessagingException ex) {
            warning("Got MessagingException.", ex);
            throw new SendFailedException("Error email, messaging parameters." , ex);
        } catch (Exception ex) {
            warning("Got Exception.", ex);
            throw new SendFailedException("Fail to process email.", ex);
        } finally {
            close();
        }
    }
View Full Code Here

      
        if ( isNullOrEmpty((Object[]) addresses)
                && isNullOrEmpty((Object[]) m.getRecipients(Message.RecipientType.TO))
                && isNullOrEmpty((Object[]) m.getRecipients(Message.RecipientType.CC))
                && isNullOrEmpty((Object[]) m.getRecipients(Message.RecipientType.BCC)) ) {
            throw new SendFailedException("No recipient addresses");
        }

        // Make sure all addresses are internet addresses
        Set<Address> invalid = new HashSet<Address>();
        for ( Address[] recipients : new Address[][] {
                m.getRecipients(Message.RecipientType.TO),
                m.getRecipients(Message.RecipientType.CC),
                m.getRecipients(Message.RecipientType.BCC),
                addresses } ) {
            if ( !isNullOrEmpty(recipients) ) {
                for ( Address a : recipients ) {
                    if ( !(a instanceof InternetAddress) ) {
                        invalid.add(a);
                    }
                }
            }
        }
       
        if ( !invalid.isEmpty() ) {
            Address[] sent = new Address[0];
            Address[] unsent = new Address[0];
            super.notifyTransportListeners(TransportEvent.MESSAGE_NOT_DELIVERED, sent, unsent,
                    invalid.toArray(new Address[invalid.size()]), m);
            throw new SendFailedException("AWS Mail Service can only send to InternetAddresses");
        }
    }
View Full Code Here

TOP

Related Classes of javax.mail.SendFailedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.