Package org.apache.james.core

Examples of org.apache.james.core.MailImpl


            } catch (Exception e) {
                out.println(ERR_RESPONSE + " Usage: DELE [mail number]");
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc == DELETED) {
                    out.println(ERR_RESPONSE + " Message (" + num + ") does not exist.");
                } else {
                    userMailbox.setElementAt(DELETED, num);
                    out.println(OK_RESPONSE + " Message removed");
View Full Code Here


                return;
            }
            //?May be written as
            //return parseCommand("TOP " + num + " " + Integer.MAX_VALUE);?
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc != DELETED) {
                    out.println(OK_RESPONSE + " Message follows");
                    OutputStream nouts =
                            new ExtraDotOutputStream(
                            new SchedulerNotifyOutputStream(outs, scheduler,
                            this.toString(), lengthReset));
                    mc.writeMessageTo(nouts);
                    out.println();
                    out.println(".");
                } else {
                    out.println(ERR_RESPONSE + " Message (" + num + ") deleted.");
                }
View Full Code Here

            } catch (NumberFormatException nfe) {
                out.println(ERR_RESPONSE + " Usage: TOP [mail number] [Line number]");
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc != DELETED) {
                    out.println(OK_RESPONSE + " Message follows");
                    for (Enumeration e = mc.getMessage().getAllHeaderLines(); e.hasMoreElements(); ) {
                        out.println(e.nextElement());
                    }
                    out.println("");
                    OutputStream nouts =
                            new ExtraDotOutputStream(
                            new SchedulerNotifyOutputStream(outs, scheduler,
                            this.toString(), lengthReset));
                    mc.writeContentTo(nouts, lines);
                    out.println(".");
                } else {
                    out.println(ERR_RESPONSE + " Message (" + num + ") already deleted.");
                }
            } catch (IOException ioe) {
View Full Code Here

            return;
        }
        List toBeRemoved =  ListUtils.subtract(backupUserMailbox, userMailbox);
        try {
            for (Iterator it = toBeRemoved.iterator(); it.hasNext(); ) {
                MailImpl mc = (MailImpl) it.next();
                userInbox.remove(mc.getName());
            }
            out.println(OK_RESPONSE + " Apache James POP3 Server signing off.");
        } catch (Exception ex) {
            out.println(ERR_RESPONSE + " Some deleted messages were not removed");
            getLogger().error("Some deleted messages were not removed: " + ex.getMessage());
View Full Code Here

        sendMail(sender, recipients, message, Mail.DEFAULT);
    }

    public void sendMail(MailAddress sender, Collection recipients, MimeMessage message, String state)
            throws MessagingException {
        MailImpl mail = new MailImpl(getId(), sender, recipients, message);
        mail.setState(state);
        sendMail(mail);
    }
View Full Code Here

        // if headers do not contains minimum REQUIRED headers fields throw Exception
        if (!headers.isValid()) {
            throw new MessagingException("Some REQURED header field is missing. Invalid Message");
        }
        ByteArrayInputStream headersIn = new ByteArrayInputStream(headers.toByteArray());
        sendMail(new MailImpl(getId(), sender, recipients, new SequenceInputStream(headersIn, msg)));
    }
View Full Code Here

        ByteArrayInputStream headersIn = new ByteArrayInputStream(headers.toByteArray());
        sendMail(new MailImpl(getId(), sender, recipients, new SequenceInputStream(headersIn, msg)));
    }

    public void sendMail(Mail mail) throws MessagingException {
        MailImpl mailimpl = (MailImpl)mail;
        try {
            spool.store(mailimpl);
        } catch (Exception e) {
            try {
                spool.remove(mailimpl);
            } catch (Exception ignored) {
            }
            throw new MessagingException("Exception spooling message: " + e.getMessage(), e);
        }
        getLogger().info("Mail " + mailimpl.getName() + " pushed in spool");
    }
View Full Code Here

            }
        }

        Collection recipients = new HashSet();
        recipients.add(recipient);
        MailImpl mailImpl = new MailImpl(getId(), sender, recipients, message);
        getUserInbox(username).store(mailImpl);
    }
View Full Code Here

    public MailImpl retrieve(String key) {
        if (DEEP_DEBUG) {
            getLogger().debug("Retrieving mail: " + key);
        }
        try {
            MailImpl mc = null;
            try {
                mc = (MailImpl) or.get(key);
            } catch (RuntimeException re) {
                getLogger().error("Exception retrieving mail: " + re + ", so we're deleting it... good ridance!");
                remove(key);
                return null;
            }
            MimeMessageAvalonSource source = new MimeMessageAvalonSource(sr, destination, key);
            mc.setMessage(new MimeMessageWrapper(source));

            return mc;
        } catch (Exception me) {
            getLogger().error("Exception retrieving mail: " + me);
            throw new RuntimeException("Exception while retrieving mail: " + me.getMessage());
View Full Code Here

                    headers.addHeaderLine((String)headerLines.nextElement());
                }

                ByteArrayInputStream headersIn
                    = new ByteArrayInputStream(headers.toByteArray());
                MailImpl mail = new MailImpl(mailServer.getId(),
                                    (MailAddress)state.get(SENDER),
                                    (Vector)state.get(RCPT_VECTOR),
                                    new SequenceInputStream(headersIn, msgIn));
                // if the message size limit has been set, we'll
                // call mail.getSize() to force the message to be
                // loaded. Need to do this to enforce the size limit
                if (maxmessagesize > 0) {
                    mail.getMessageSize();
                }
                mail.setRemoteHost((String)state.get(REMOTE_NAME));
                mail.setRemoteAddr((String)state.get(REMOTE_IP));
                mailServer.sendMail(mail);
            } catch (MessagingException me) {
                //Grab any exception attached to this one.
                Exception e = me.getNextException();
View Full Code Here

TOP

Related Classes of org.apache.james.core.MailImpl

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.