Package javax.mail

Examples of javax.mail.URLName


          if (aValue != null) {
            anIndex = ((String) aValue).indexOf(' ');
            if (anIndex > 0) {
              String aService = ((String) aValue)
                  .substring(anIndex + 1);
              URLName aServiceURL = new URLName(
                  MXLookup.SMTPScheme + aService);
              serviceURLsList.add(aServiceURL);
            }
          }
        }// END for (int index = 0; index < count; index++)
      } // END for (NamingEnumeration anEnumeration =
      // someAttributes
      //     .getIDs(); anEnumeration.hasMore();)
      dirContext.close();
      if (!serviceURLsList.isEmpty()) {
        //Collections.shuffle(serviceURLsList);
        //return (URLName) serviceURLsList.get(0);
        return serviceURLsList;
      }
      ArrayList defaultArrayList = new ArrayList();
      defaultArrayList.add(new URLName(MXLookup.SMTPScheme + host));
      return defaultArrayList;
    }
    throw new IllegalArgumentException(
        "MXLookup.urlForAddress: null address.");
  }
View Full Code Here


      }
      MessagingException lastError = null;
      Iterator<URLName> i = targetServers.iterator();
      while (i.hasNext()) {
        try {
          URLName outgoingMailServer = (URLName) i.next();
          StringBuffer logMessageBuffer = null;
          if( log.isDebugEnabled() )
          {
            logMessageBuffer = new StringBuffer(256)
              .append(getClass().getSimpleName())
              .append(" (")
              .append(getName())
              .append(").deliver(): ")
              .append("Attempting delivery of ")
              .append(mail.getName())
              .append(" to host ")
              .append(outgoingMailServer.toString())
              .append(" to addresses ")
              .append(Arrays.asList(addr));
            log.debug(logMessageBuffer.toString());
          }
          Properties props = session.getProperties();
View Full Code Here

                recordsColl = new Vector<URLName>(records.length);
                for (int i = 0; i < records.length; i++)
        {
          MXRecord mx = (MXRecord) records[i];
          String targetString = mx.getTarget().toString();
          URLName uName = new URLName(
              RemoteDelivery.SMTPScheme +
              targetString.substring(0, targetString.length() - 1)
          );
          recordsColl.add(uName);
        }
            }else
            {
              foundOriginalMX = false;
              recordsColl = new Vector<URLName>();
            }
           
            /*
             * If we found no MX record for the original hostname (the upper
             * level domains does not matter), then we add the original domain
             * name (identified with an A record) to the record collection,
             * because the mail exchange server could be the main server too.
       *
       * We append the A record to the first place of the record
       * collection, because the standard says if no MX record found then
       * we should to try send email to the server identified by the A
       * record.
             */
      if( !foundOriginalMX )
      {
        Record[] recordsTypeA = new Lookup(hostName, Type.A).run();
        if (recordsTypeA != null && recordsTypeA.length > 0)
        {
          recordsColl.add(0, new URLName(RemoteDelivery.SMTPScheme + hostName));
        }
      }

    } catch (TextParseException e) {
      log.warn(getClass().getSimpleName()+" ("+getName()+").getMXRecordsForHost(): Failed get MX record.",e);
View Full Code Here

            } catch (ContextException ce) {

                // imap://{userid}:{password}@host:port/
                storeURLNameExpanded = getURLNameExpanded(storeURLNameTemplate, userid, password);

                URLName urlNameExpanded = new URLName(storeURLNameExpanded);
                getLogger().info("get store using URLName " + String.valueOf(urlNameExpanded));
                mailStore = mailSession.getStore(urlNameExpanded);
                mailStore.connect();
                mailContext.put(MailContext.MAIL_STORE_ENTRY, mailStore);
            }
View Full Code Here

        String password = "";
        String host = "";
        String protocol = "";
        String port = "";
        URLName urlName;

        for (Iterator iterator = mailParameters.iterator(); iterator.hasNext();) {
            Parameter param = (Parameter) iterator.next();
            String paramKey = param.getName();
            String paramValue = Utils.getParameterValue(param);
            if (paramKey == null || paramValue == null) {
                String error = Messages.getMessage("canNotBeNull", "Parameter name and value");
                log.error(error);
                throw new AxisFault(error);

            }
            pop3Properties.setProperty(paramKey, paramValue);
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_USER)) {
                user = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_PASSWORD)) {
                password = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_HOST)) {
                host = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.STORE_PROTOCOL)) {
                protocol = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_PORT)) {
                port = paramValue;
            }

            //Transport specific
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.REPLY_TO)) {
                replyTo = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.LISTENER_INTERVAL)) {
                listenerWaitInterval = Integer.parseInt(paramValue);
            }

        }
        if (password.length() == 0 || user.length() == 0 || host.length() == 0 ||
            protocol.length() == 0) {
            String error = SimpleMailListener.class.getName() +
                           " one or more of Password, User, Host and Protocol are null or empty";
            log.error(error);
            throw new AxisFault(error);
        }

        if (port.length() == 0) {
            urlName = new URLName(protocol, host, -1, "", user, password);
        } else {
            urlName = new URLName(protocol, host, Integer.parseInt(port), "", user, password);
        }

        receiver.setPop3Properties(pop3Properties);
        receiver.setUrlName(urlName);
        Object obj = configurationContext.
View Full Code Here

        String password = "";
        String host = "";
        String protocol = "";
        String port = "";
        URLName urlName;

        pop3Properties.clear();
        pop3Properties.putAll(properties);

        user = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_USER);
        password = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_PASSWORD);
        host = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_HOST);
        protocol = properties.getProperty(org.apache.axis2.transport.mail.Constants.STORE_PROTOCOL);
        port = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_PORT);
        replyTo = properties.getProperty(org.apache.axis2.transport.mail.Constants.REPLY_TO);
        String value =
                properties.getProperty(org.apache.axis2.transport.mail.Constants.LISTENER_INTERVAL);
        if (value != null) {
            listenerWaitInterval = Integer.parseInt(value);
        }

        if (password.length() == 0 || user.length() == 0 || host.length() == 0 ||
            protocol.length() == 0) {
            String error = SimpleMailListener.class.getName() + " one or more of Password, User," +
                           " Host and Protocol are null or empty" + "in runtime settings";
            log.error(error);
            throw new AxisFault(error);
        }

        if (port == null) {
            urlName = new URLName(protocol, host, -1, "", user, password);
        } else {
            urlName = new URLName(protocol, host, Integer.parseInt(port), "", user, password);
        }

        receiver.setPop3Properties(pop3Properties);
        receiver.setUrlName(urlName);
        Object obj = configurationContext.
View Full Code Here

                msg.setContent(content, "text/plain");
                msg.saveChanges();

                SMTPTransport smtpTrans = null;
                if (_smtpUseAuth) {
                    smtpTrans = new SMTPSSLTransport(_smtpSession, new URLName("smtp", _smtpHost, _smtpPort, null, _smtpUsername, _smtpPassword));
                } else {
                    smtpTrans = new SMTPTransport(_smtpSession, new URLName("smtp", _smtpHost, _smtpPort, null, _smtpUsername, _smtpPassword));
                }
                smtpTrans.connect();
                smtpTrans.sendMessage(msg, msg.getAllRecipients());
                smtpTrans.close();
            }
View Full Code Here

        String password = "";
        String host = "";
        String protocol = "";
        String port = "";
        URLName urlName;

        for (Iterator iterator = mailParameters.iterator(); iterator.hasNext();) {
            Parameter param = (Parameter) iterator.next();
            String paramKey = param.getName();
            String paramValue = Utils.getParameterValue(param);
            if (paramKey == null || paramValue == null) {
                throw new AxisFault(Messages.getMessage("canNotBeNull",
                                                        "Parameter name nor value should be null"));

            }
            pop3Properties.setProperty(paramKey, paramValue);
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_USER)) {
                user = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_PASSWORD)) {
                password = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_HOST)) {
                host = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.STORE_PROTOCOL)) {
                protocol = paramValue;
            }
            if (paramKey.equals(org.apache.axis2.transport.mail.Constants.POP3_PORT)) {
                port = paramValue;
            }

        }
        if (password.length() == 0 || user.length() == 0 || host.length() == 0 || protocol.length() == 0) {
            throw new AxisFault("One or more of Password, User, Host and Protocol are null or empty");
        }

        if (port.length() == 0) {
            urlName = new URLName(protocol, host, -1, "", user, password);
        } else {
            urlName = new URLName(protocol, host, Integer.parseInt(port), "", user, password);
        }

        receiver = new EmailReceiver();
        receiver.setPop3Properties(pop3Properties);
        receiver.setUrlName(urlName);
View Full Code Here

            throw new ContainerException(e);
        }

        // re-write the URLName including the password for this store
        if (store != null && store.getURLName() != null) {
            URLName urlName = this.updateUrlName(store.getURLName(), session.getProperties());
            if (Debug.verboseOn()) Debug.logVerbose("URLName - " + urlName.toString(), module);
            try {
                store = session.getStore(urlName);
            } catch (NoSuchProviderException e) {
                throw new ContainerException(e);
            }
View Full Code Here

                host = props.getProperty("mail.host");
            }
        }

        if (Debug.verboseOn()) Debug.logVerbose("Update URL - " + protocol + "://" + userName + "@" + host + ":" + port + "!" + password + ";" + file, module);
        return new URLName(protocol, host, port, file, userName, password);
    }
View Full Code Here

TOP

Related Classes of javax.mail.URLName

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.