Package org.apache.james.core

Examples of org.apache.james.core.MailImpl


        InternetAddress addr[] = { new InternetAddress(mail.getSender().toString()) };
        reply.setRecipients(Message.RecipientType.TO, addr);
        reply.setFrom(new InternetAddress(mail.getRecipients().iterator().next().toString()));
        reply.setText(bounceText);
        reply.setHeader(RFC2822Headers.MESSAGE_ID, "replyTo-" + mail.getName());
        return new MailImpl("replyTo-" + mail.getName(), new MailAddress(mail.getRecipients().iterator().next().toString()), recipients, reply);
    }
View Full Code Here


     * (non-Javadoc)
     * @see org.apache.mailet.MailetContext#sendMail(org.apache.mailet.MailAddress, java.util.Collection, javax.mail.internet.MimeMessage, java.lang.String)
     */
    @SuppressWarnings("unchecked")
  public void sendMail(MailAddress sender, Collection recipients, MimeMessage message, String state) throws MessagingException {
        MailImpl mail = new MailImpl(mailServer.getId(), sender, recipients, message);
        try {
            mail.setState(state);
            sendMail(mail);
        } finally {
            LifecycleUtil.dispose(mail);
        }
    }
View Full Code Here

     * @throws MessagingException if an exception is caught while placing the mail
     *                            on the spool
     */
    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

     *
     * @throws MessagingException if an exception is caught while placing the mail
     *                            on the spool
     */
    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);
        }
        if (getLogger().isDebugEnabled()) {
            StringBuffer logBuffer =
                new StringBuffer(64)
                        .append("Mail ")
                        .append(mailimpl.getName())
                        .append(" pushed in spool");
            getLogger().debug(logBuffer.toString());
        }
    }
View Full Code Here

                throw new RuntimeException("Exception storing mail: " + e);
            }
        } else {
            Collection recipients = new HashSet();
            recipients.add(recipient);
            MailImpl mailImpl = new MailImpl(getId(), sender, recipients, message);
            MailRepository userInbox = getUserInbox(username);
            if (userInbox == null) {
                StringBuffer errorBuffer =
                    new StringBuffer(128)
                        .append("The inbox for user ")
View Full Code Here

            if (argument == null) {
                responseString = OK_RESPONSE + " unique-id listing follows";
                writeLoggedFlushedResponse(responseString);
                int count = 0;
                for (Enumeration e = userMailbox.elements(); e.hasMoreElements(); count++) {
                    MailImpl mc = (MailImpl) e.nextElement();
                    if (mc != DELETED) {
                        StringBuffer responseBuffer =
                            new StringBuffer(64)
                                    .append(count)
                                    .append(" ")
                                    .append(mc.getName());
                        out.println(responseBuffer.toString());
                    }
                }
                out.println(".");
                out.flush();
            } else {
                int num = 0;
                try {
                    num = Integer.parseInt(argument);
                    MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                    if (mc != DELETED) {
                        StringBuffer responseBuffer =
                            new StringBuffer(64)
                                    .append(OK_RESPONSE)
                                    .append(" ")
                                    .append(num)
                                    .append(" ")
                                    .append(mc.getName());
                        responseString = responseBuffer.toString();
                        writeLoggedFlushedResponse(responseString);
                    } else {
                        StringBuffer responseBuffer =
                            new StringBuffer(64)
View Full Code Here

                responseString = ERR_RESPONSE + " Usage: DELE [mail number]";
                writeLoggedFlushedResponse(responseString);
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc == DELETED) {
                    StringBuffer responseBuffer =
                        new StringBuffer(64)
                                .append(ERR_RESPONSE)
                                .append(" Message (")
View Full Code Here

                responseString = ERR_RESPONSE + " Usage: RETR [mail number]";
                writeLoggedFlushedResponse(responseString);
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc != DELETED) {
                    responseString = OK_RESPONSE + " Message follows";
                    writeLoggedFlushedResponse(responseString);
                    OutputStream nouts =
                            new ExtraDotOutputStream(outs);
                    nouts = new BytesWrittenResetOutputStream(nouts,
                                                              theWatchdog,
                                                              theConfigData.getResetLength());
                    mc.writeMessageTo(nouts);
                    nouts.flush();
                    // TODO: Is this an extra CRLF?
                    out.println();
                    out.println(".");
                    out.flush();
View Full Code Here

                responseString = ERR_RESPONSE + " Usage: TOP [mail number] [Line number]";
                writeLoggedFlushedResponse(responseString);
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc != DELETED) {
                    responseString = OK_RESPONSE + " Message follows";
                    writeLoggedFlushedResponse(responseString);
                    for (Enumeration e = mc.getMessage().getAllHeaderLines(); e.hasMoreElements(); ) {
                        out.println(e.nextElement());
                    }
                    out.println();
                    OutputStream nouts =
                            new ExtraDotOutputStream(outs);
                    nouts = new BytesWrittenResetOutputStream(nouts,
                                                              theWatchdog,
                                                              theConfigData.getResetLength());
                    mc.writeContentTo(nouts, lines);
                    nouts.flush();
                    out.println(".");
                    out.flush();
                } else {
                    StringBuffer responseBuffer =
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.