Пример #1
0
 /* validate the syntax of the specified list of multiple email addresses */
 public static boolean validateAddresses(String addrs, boolean acceptSMS) {
   if (StringTools.isBlank(addrs)) {
     // blank is ok in this case
     return true;
   } else if (acceptSMS) {
     // allow "sms:123456789" format
     String addrArry[] = StringTools.parseStringArray(addrs, ',');
     if (addrArry.length == 0) {
       return false;
     }
     for (int i = 0; i < addrArry.length; i++) {
       String em = addrArry[i].trim();
       if (StringTools.isBlank(em)) {
         // individual addresses not allowed
         return false;
       } else if (SMSOutboundGateway.StartsWithSMS(em)) {
         // TODO: for now, accept as-is
       } else if (!validateAddress(em)) {
         return false;
       }
     }
     return true;
   } else {
     // true email addresses only
     try {
       return SendMail.validateAddresses(addrs);
     } catch (Throwable t) { // NoClassDefFoundException, ClassNotFoundException
       // this will fail if JavaMail support for SendMail is not available.
       Print.logError("*** SendMail error: " + t);
       return false;
     }
   }
 }