Package javax.mail.internet

Examples of javax.mail.internet.AddressException


      System.exit(1);
    }
   
    try {
      if (!MailUtil.matches(cfg.email)) {
          throw new AddressException("Invalid address");
      }
      new InternetAddress(cfg.email, true);
    } catch (AddressException ae) {
      System.out.println("Please provide non-empty valid email: '" + cfg.email + "' is not valid.");
      System.exit(1);
View Full Code Here


      from = from.trim().toLowerCase();
      to = to.trim().toLowerCase();
     
      boolean fromOk = from.matches(emailRegexp);
      if(!fromOk)
        throw new AddressException("Invalid from address:" + from);

      boolean toOk = to.matches(emailRegexp);
      if(!toOk)
        throw new AddressException("Invalid to address:" + to);
     
      if(cc != null && !cc.equals(""))
      {
        StringBuffer sb = new StringBuffer();
        String[] emailAddresses = cc.split(";");
          for(int i=0; i<emailAddresses.length; i++)
          {
              String email = emailAddresses[i].trim().toLowerCase();
              boolean emailOk = email.matches(emailRegexp);
            if(!emailOk && emailAddresses.length == 1)
              {
                throw new AddressException("Invalid cc address:" + email);
              }
              else if(emailOk)
              {
                if(sb.length() > 0)
                  sb.append(";");
                sb.append(email);
              }
          }
         
          cc = sb.toString();
          if(cc.equals(""))
            cc = null;
      }
     
      if(cc != null && cc.equals(""))
          cc = null;

      if(bcc == null && recipients != null)
        bcc = recipients;
       
      if(bcc != null && !bcc.equals(""))
      {
        StringBuffer sb = new StringBuffer();
        String[] emailAddresses = bcc.split(";");
          for(int i=0; i<emailAddresses.length; i++)
          {
              String email = emailAddresses[i].trim().toLowerCase();
              boolean emailOk = email.matches(emailRegexp);
            if(!emailOk && emailAddresses.length == 1)
              {
                throw new AddressException("Invalid bcc/recipients address:" + email);
              }
              else if(emailOk)
              {
                if(sb.length() > 0)
                  sb.append(";");
View Full Code Here

      System.exit(1);
    }
   
    try {
      if (!MailUtil.matches(admin.email)) {
          throw new AddressException("Invalid address");
      }
      new InternetAddress(admin.email, true);
    } catch (AddressException ae) {
      System.out.println("Please provide non-empty valid email: '" + admin.email + "' is not valid.");
      System.exit(1);
View Full Code Here

   */
  public InternetAddress toInternetAddress() throws AddressException {
    try {
      return new InternetAddress(email, personalName, JoddCore.encoding);
    } catch (UnsupportedEncodingException ueex) {
      throw new AddressException(ueex.toString());
    }
  }
View Full Code Here

TOP

Related Classes of javax.mail.internet.AddressException

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.