Examples of MailImpl


Examples of org.apache.james.core.MailImpl

        if (state == TRANSACTION) {
            long size = 0;
            int count = 0;
            try {
                for (Enumeration e = userMailbox.elements(); e.hasMoreElements(); ) {
                    MailImpl mc = (MailImpl) e.nextElement();
                    if (mc != DELETED) {
                        size += mc.getMessageSize();
                        count++;
                    }
                }
                out.println(OK_RESPONSE + " " + count + " " + size);
            } catch (MessagingException me) {
View Full Code Here

Examples of org.apache.james.core.MailImpl

            if (argument == null) {
                long size = 0;
                int count = 0;
                try {
                    for (Enumeration e = userMailbox.elements(); e.hasMoreElements(); ) {
                        MailImpl mc = (MailImpl) e.nextElement();
                        if (mc != DELETED) {
                            size += mc.getMessageSize();
                            count++;
                        }
                    }
                    out.println(OK_RESPONSE + " " + count + " " + size);
                    count = 0;
                    for (Enumeration e = userMailbox.elements(); e.hasMoreElements(); count++) {
                        MailImpl mc = (MailImpl) e.nextElement();
                        if (mc != DELETED) {
                            out.println(count + " " + mc.getMessageSize());
                        }
                    }
                    out.println(".");
                } catch (MessagingException me) {
                    out.println(ERR_RESPONSE);
                }
            } else {
                int num = 0;
                try {
                    num = Integer.parseInt(argument);
                    MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                    if (mc != DELETED) {
                        out.println(OK_RESPONSE + " " + num + " " + mc.getMessageSize());
                    } else {
                        out.println(ERR_RESPONSE + " Message (" + num + ") does not exist.");
                    }
                } catch (ArrayIndexOutOfBoundsException npe) {
                    out.println(ERR_RESPONSE + " Message (" + num + ") does not exist.");
View Full Code Here

Examples of org.apache.james.core.MailImpl

        }

    }

    public void service(Mail genericmail) {
        MailImpl mail = (MailImpl)genericmail;
        log("Storing mail " + mail.getName() + " in " + repositoryPath);
        repository.store(mail);
        if (!passThrough) {
            mail.setState(Mail.GHOST);
        }
    }
View Full Code Here

Examples of org.apache.james.core.MailImpl

     *
     * @param mail org.apache.mailet.Mail
     * @return org.apache.mailet.MessageContainer
     */
    public void service(Mail genericmail) throws AddressException {
        MailImpl mail = (MailImpl)genericmail;

        //Do I want to give the internal key, or the message's Message ID
        log("Remotely delivering mail " + mail.getName());
        Collection recipients = mail.getRecipients();

        //Must first organize the recipients into distinct servers (name made case insensitive)
        Hashtable targets = new Hashtable();
        for (Iterator i = recipients.iterator(); i.hasNext();) {
            MailAddress target = (MailAddress)i.next();
            String targetServer = target.getHost().toLowerCase();
            Collection temp = (Collection)targets.get(targetServer);
            if (temp == null) {
                temp = new Vector();
                targets.put(targetServer, temp);
            }
            temp.add(target);
        }

        //We have the recipients organized into distinct servers... put them into the
        //delivery store organized like this... this is ultra inefficient I think...

        //store the new message containers, organized by server, in the outgoing mail repository
        String name = mail.getName();
        for (Iterator i = targets.keySet().iterator(); i.hasNext(); ) {
            String host = (String) i.next();
            Collection rec = (Collection) targets.get(host);
            log("sending mail to " + rec + " on host " + host);
            mail.setRecipients(rec);
            mail.setName(name + "-to-" + host);
            outgoing.store(mail);
            //Set it to try to deliver (in a separate thread) immediately (triggered by storage)
        }
        mail.setState(Mail.GHOST);
    }
View Full Code Here

Examples of org.apache.james.core.MailImpl

        while (!Thread.currentThread().interrupted() && !destroyed) {
            try {
                String key = outgoing.accept(delayTime);
                try {
                   log(Thread.currentThread().getName() + " will process mail " + key);
                   MailImpl mail = outgoing.retrieve(key);
                   if (deliver(mail, session)) {
                       //Message was successfully delivered/fully failed... delete it
                       outgoing.remove(key);
                   } else {
                       //Something happened that will delay delivery.  Store any updates
View Full Code Here

Examples of org.apache.james.core.MailImpl

                                .append(repositoryName);
                    getLogger().debug(debugBuffer.toString());
                }
                return null;
            }
            MailImpl mc = new MailImpl();
            mc.setName(key);
            mc.setState(rsMessage.getString(1));
            mc.setErrorMessage(rsMessage.getString(2));
            String sender = rsMessage.getString(3);
            if (sender == null) {
                mc.setSender(null);
            } else {
                mc.setSender(new MailAddress(sender));
            }
            StringTokenizer st = new StringTokenizer(rsMessage.getString(4), "\r\n", false);
            Set recipients = new HashSet();
            while (st.hasMoreTokens()) {
                recipients.add(new MailAddress(st.nextToken()));
            }
            mc.setRecipients(recipients);
            mc.setRemoteHost(rsMessage.getString(5));
            mc.setRemoteAddr(rsMessage.getString(6));
            mc.setLastUpdated(rsMessage.getTimestamp(7));

            MimeMessageJDBCSource source = new MimeMessageJDBCSource(this, key, sr);
            MimeMessageWrapper message = new MimeMessageWrapper(source);
            mc.setMessage(message);
            return mc;
        } catch (SQLException sqle) {
            synchronized (System.err) {
                System.err.println("Error retrieving message");
                System.err.println(sqle.getMessage());
View Full Code Here

Examples of org.apache.james.core.MailImpl

                    //We have a lock on this object... let's grab the message
                    //  and see if it's a valid time.

                    // Retrieve can return null if the mail is no longer in the store.
                    // In this case we simply continue to the next key
                    MailImpl mail = retrieve(s);
                    if (mail == null) {
                        continue;
                    }
                    if (mail.getState().equals(Mail.ERROR)) {
                        //Test the time...
                        long timeToProcess = delay + mail.getLastUpdated().getTime();
                        if (System.currentTimeMillis() > timeToProcess) {
                            //We're ready to process this again
                            return s;
                        } else {
                            //We're not ready to process this.
View Full Code Here

Examples of org.apache.james.core.MailImpl

            }
            if (notRecipients.size() != 0) {
                // There are a mix of recipients and not recipients.
                // We need to clone this message, put the notRecipients on the clone
                // and store it in the next spot
                MailImpl notMail = (MailImpl)mail.duplicate(newName(mail));
                notMail.setRecipients(notRecipients);
                unprocessed[i + 1].add(notMail);
                //We have to set the reduce possible recipients on the old message
                mail.setRecipients(recipients);
            }
            // We have messages that need to process... time to run the mailet.
View Full Code Here

Examples of org.apache.james.core.MailImpl

        }

        while(true) {
            try {
                String key = spool.accept();
                MailImpl mail = spool.retrieve(key);
                // Retrieve can return null if the mail is no longer on the spool
                // (i.e. another thread has gotten to it first).
                // In this case we simply continue to the next key
                if (mail == null) {
                    continue;
                }
                if (getLogger().isDebugEnabled()) {
                    StringBuffer debugBuffer =
                        new StringBuffer(64)
                                .append("==== Begin processing mail ")
                                .append(mail.getName())
                                .append("====");
                    getLogger().debug(debugBuffer.toString());
                }
                process(mail);
                // Only remove an email from the spool is processing is
                // complete, or if it has no recipients
                if ((Mail.GHOST.equals(mail.getState())) ||
                    (mail.getRecipients() == null) ||
                    (mail.getRecipients().size() == 0)) {
                    spool.remove(key);
                    if (getLogger().isDebugEnabled()) {
                        StringBuffer debugBuffer =
                            new StringBuffer(64)
                                    .append("==== Removed from spool mail ")
                                    .append(mail.getName())
                                    .append("====");
                        getLogger().debug(debugBuffer.toString());
                    }
                }
                else {
View Full Code Here

Examples of org.apache.james.core.MailImpl

     * @param msgIn the stream containing the message content
     */
    private void processMail(MailHeaders headers, InputStream msgIn)
        throws MessagingException {
        ByteArrayInputStream headersIn = null;
        MailImpl mail = null;
        List recipientCollection = null;
        try {
            headersIn = new ByteArrayInputStream(headers.toByteArray());
            recipientCollection = (List) state.get(RCPT_LIST);
            mail =
                new MailImpl(theConfigData.getMailServer().getId(),
                             (MailAddress) state.get(SENDER),
                             recipientCollection,
                             new SequenceInputStream(headersIn, msgIn));
            // Call mail.getSize() to force the message to be
            // loaded. Need to do this to enforce the size limit
            if (theConfigData.getMaxMessageSize() > 0) {
                mail.getMessageSize();
            }
            mail.setRemoteHost(remoteHost);
            mail.setRemoteAddr(remoteIP);
            theConfigData.getMailServer().sendMail(mail);
            Collection theRecipients = mail.getRecipients();
            String recipientString = "";
            if (theRecipients != null) {
                recipientString = theRecipients.toString();
            }
            if (getLogger().isDebugEnabled()) {
                StringBuffer debugBuffer =
                    new StringBuffer(256)
                        .append("Successfully spooled mail )")
                        .append(mail.getName())
                        .append(" from ")
                        .append(mail.getSender())
                        .append(" for ")
                        .append(recipientString);
                getLogger().debug(debugBuffer.toString());
            } else if (getLogger().isInfoEnabled()) {
                StringBuffer infoBuffer =
                    new StringBuffer(256)
                        .append("Successfully spooled mail from ")
                        .append(mail.getSender())
                        .append(" for ")
                        .append(recipientString);
                getLogger().info(infoBuffer.toString());
            }
        } finally {
            if (recipientCollection != null) {
                recipientCollection.clear();
            }
            recipientCollection = null;
            if (mail != null) {
                mail.dispose();
            }
            mail = null;
            if (headersIn != null) {
                try {
                    headersIn.close();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.