Package org.apache.mailet

Examples of org.apache.mailet.Mail


        // If the IP address and host name for the remote domain cannot
        // be found, we will get an UnknownHostException.
        // In both cases, we log the problem and
        // return. The message disposition is defined by the
        // <undeliverable> attributes.
        Mail mail = null;
        try
        {
            mail = createMail(createMessage(), intendedRecipient);
        }
        catch (ParseException ex)
View Full Code Here


        LifecycleUtil.dispose(m_mailServer);
        super.tearDown();
    }

    public void verifyLastMail(String sender, String recipient, MimeMessage msg) throws IOException, MessagingException {
        Mail mailData = m_mailServer.getLastMail();
        assertNotNull("mail received by mail server", mailData);

        if (sender == null && recipient == null && msg == null)
            fail("no verification can be done with all arguments null");

        if (sender != null)
            assertEquals("sender verfication", sender, mailData.getSender().toString());
        if (recipient != null)
            assertTrue("recipient verfication", mailData.getRecipients().contains(new MailAddress(recipient)));
        if (msg != null) {
            ByteArrayOutputStream bo1 = new ByteArrayOutputStream();
            msg.writeTo(bo1);
            ByteArrayOutputStream bo2 = new ByteArrayOutputStream();
            mailData.getMessage().writeTo(bo2);
            assertEquals(bo1.toString(), bo2.toString());
            assertEquals("message verification", msg, mailData.getMessage());
        }
    }
View Full Code Here

        if (throwException) {
            throwException = false;
            throw new MailQueueException("Mock");
        }
        try {
          final Mail mail = queue.take();
            return new MailQueueItem() {
       
        public Mail getMail() {
          return mail;
        }
View Full Code Here

    }

    @Override
    protected MailQueueItem createMailQueueItem(Connection connection, Session session, MessageConsumer consumer, Message message) throws JMSException, MessagingException {
        Mail mail = createMail(message);
        return new ActiveMQMailQueueItem(mail, connection, session, consumer, message, logger);
    }
View Full Code Here

    public Mail retrieve(String key) throws MessagingException {
        if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
            getLogger().debug("Retrieving mail: " + key);
        }
        try {
            Mail mc = null;
            try {
                mc = (Mail) objectRepository.get(key);
            }
            catch (RuntimeException re){
                StringBuffer exceptionBuffer = new StringBuffer(128);
                if(re.getCause() instanceof Error){
                    exceptionBuffer.append("Error when retrieving mail, not deleting: ")
                            .append(re.toString());
                }else{
                    exceptionBuffer.append("Exception retrieving mail: ")
                            .append(re.toString())
                            .append(", so we're deleting it.");
                    remove(key);
                }
                final String errorMessage = exceptionBuffer.toString();
                getLogger().warn(errorMessage);
                getLogger().debug(errorMessage, re);
                return null;
            }
            MimeMessageAvalonSource source = new MimeMessageAvalonSource(streamRepository, destination, key);
            mc.setMessage(new MimeMessageCopyOnWriteProxy(source));

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

    public Response onCommand(POP3Session session, Request request) {
        POP3Response response = null;
        String parameters = request.getArgument();
       
        if (session.getHandlerState() == POP3Session.TRANSACTION) {
            Mail dm = (Mail) session.getState().get(POP3Session.DELETED);

            if (parameters == null) {

                long size = 0;
                int count = 0;
View Full Code Here

     *
     */
    @SuppressWarnings("unchecked")
    protected void stat(POP3Session session) {
        ArrayList<Mail> userMailbox = new ArrayList<Mail>();
        Mail dm = (Mail) session.getState().get(POP3Session.DELETED);

        userMailbox.add(dm);
        try {
            for (Iterator it = session.getUserInbox().list(); it.hasNext(); ) {
                String key = (String) it.next();
                Mail mc = session.getUserInbox().retrieve(key);
                // Retrieve can return null if the mail is no longer in the store.
                // In this case we simply continue to the next key
                if (mc == null) {
                    continue;
                }
View Full Code Here

            } catch (NumberFormatException nfe) {
                response = new POP3Response(POP3Response.ERR_RESPONSE, "Usage: TOP [mail number] [Line number]");
                return response;
            }
            try {
                Mail mc = session.getUserMailbox().get(num);
                Mail dm = (Mail) session.getState().get(POP3Session.DELETED);

                if (mc != dm) {
                    response = new POP3Response(POP3Response.OK_RESPONSE, "Message follows");
                    try {
                        for (Enumeration e = mc.getMessage().getAllHeaderLines(); e.hasMoreElements(); ) {
View Full Code Here

            } catch (Exception e) {
                response = new POP3Response(POP3Response.ERR_RESPONSE,"Usage: DELE [mail number]");
                return response;
            }
            try {
                Mail mc = session.getUserMailbox().get(num);
                Mail dm = (Mail) session.getState().get(POP3Session.DELETED);
                if (mc == dm) {
                    StringBuilder responseBuffer =
                        new StringBuilder(64)
                                .append("Message (")
                                .append(num)
View Full Code Here

   */
    public Response onCommand(POP3Session session, Request request) {
        POP3Response response = null;
        String parameters = request.getArgument();
        if (session.getHandlerState() == POP3Session.TRANSACTION) {
            Mail dm = (Mail) session.getState().get(POP3Session.DELETED);

            if (parameters == null) {
                response = new POP3Response(POP3Response.OK_RESPONSE,"unique-id listing follows");
                int count = 0;
                for (Mail mc:session.getUserMailbox()) {
                    if (mc != dm) {
                        StringBuilder responseBuffer =
                            new StringBuilder(64)
                                    .append(count)
                                    .append(" ")
                                    .append(mc.getName());
                        response.appendLine(responseBuffer.toString());
                    }
                    count++;
                }
                response.appendLine(".");
            } else {
                int num = 0;
                try {
                    num = Integer.parseInt(parameters);
                    Mail mc = (Mail) session.getUserMailbox().get(num);
                    if (mc != dm) {
                        StringBuilder responseBuffer =
                            new StringBuilder(64)
                                    .append(num)
                                    .append(" ")
                                    .append(mc.getName());
                        response = new POP3Response(POP3Response.OK_RESPONSE, responseBuffer.toString());

                    } else {
                        StringBuilder responseBuffer =
                            new StringBuilder(64)
View Full Code Here

TOP

Related Classes of org.apache.mailet.Mail

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.