Examples of MailHeaders


Examples of org.apache.james.core.MailHeaders

    private void createArticle() {
        try {
            InputStream msgIn = new CharTerminatedInputStream(in, NNTPTerminator);
            // Removes the dot stuffing
            msgIn = new DotStuffingInputStream(msgIn);
            MailHeaders headers = new MailHeaders(msgIn);
            processMessageHeaders(headers);
            processMessage(headers, msgIn);
        } catch (MessagingException me) {
            throw new NNTPException("MessagingException encountered when loading article.");
        }
View Full Code Here

Examples of org.apache.james.core.MailHeaders

     */
    public void writeHead(OutputStream out) {
        FileInputStream fileStream = null;
        try {
            fileStream = new FileInputStream(articleFile);
            MailHeaders headers = new MailHeaders(fileStream);
            byte[] headerBuffer = headers.toByteArray();
            int headerBufferLength = headerBuffer.length;
            // Write the headers excluding the final CRLF pair
            if (headerBufferLength > 2) {
                out.write(headerBuffer, 0, (headerBufferLength - 2));
            }
View Full Code Here

Examples of org.apache.james.core.MailHeaders

     */
    public void writeBody(OutputStream out) {
        FileInputStream fileStream = null;
        try {
            fileStream = new FileInputStream(articleFile);
            MailHeaders headers = new MailHeaders(fileStream);
            byte[] readBuffer = new byte[1024];
            int read = 0;
            while ((read = fileStream.read(readBuffer)) > 0) {
                out.write(readBuffer, 0, read);
            }
View Full Code Here

Examples of org.apache.james.core.MailHeaders

     *                            on the spool
     */
    public void sendMail(MailAddress sender, Collection recipients, InputStream msg)
            throws MessagingException {
        // parse headers
        MailHeaders headers = new MailHeaders(msg);

        // 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

Examples of org.apache.james.core.MailHeaders

                    msgIn = new SizeLimitedInputStream(msgIn, maxMessageSize);
                }
                // Removes the dot stuffing
                msgIn = new DotStuffingInputStream(msgIn);
                // Parse out the message headers
                MailHeaders headers = new MailHeaders(msgIn);
                headers = processMailHeaders(headers);
                processMail(headers, msgIn);
                headers = null;
            } catch (MessagingException me) {
                // Grab any exception attached to this one.
View Full Code Here

Examples of org.apache.james.core.MailHeaders

            }
        }
        // We will rebuild the header object to put Return-Path and our
        // Received header at the top
        Enumeration headerLines = headers.getAllHeaderLines();
        MailHeaders newHeaders = new MailHeaders();
        // Put the Return-Path first
        newHeaders.addHeaderLine(RFC2822Headers.RETURN_PATH + ": " + returnPath);
        // Put our Received header next
        headerLineBuffer.append(RFC2822Headers.RECEIVED + ": from ")
                        .append(remoteHost)
                        .append(" ([")
                        .append(remoteIP)
                        .append("])");

        newHeaders.addHeaderLine(headerLineBuffer.toString());
        headerLineBuffer.delete(0, headerLineBuffer.length());

        headerLineBuffer.append("          by ")
                        .append(theConfigData.getHelloName())
                        .append(" (")
                        .append(SOFTWARE_TYPE)
                        .append(") with SMTP ID ")
                        .append(smtpID);

        if (((Collection) state.get(RCPT_LIST)).size() == 1) {
            // Only indicate a recipient if they're the only recipient
            // (prevents email address harvesting and large headers in
            //  bulk email)
            newHeaders.addHeaderLine(headerLineBuffer.toString());
            headerLineBuffer.delete(0, headerLineBuffer.length());
            headerLineBuffer.append("          for <")
                            .append(((List) state.get(RCPT_LIST)).get(0).toString())
                            .append(">;");
            newHeaders.addHeaderLine(headerLineBuffer.toString());
            headerLineBuffer.delete(0, headerLineBuffer.length());
        } else {
            // Put the ; on the end of the 'by' line
            headerLineBuffer.append(";");
            newHeaders.addHeaderLine(headerLineBuffer.toString());
            headerLineBuffer.delete(0, headerLineBuffer.length());
        }
        headerLineBuffer = null;
        newHeaders.addHeaderLine("          " + rfc822DateFormat.format(new Date()));

        // Add all the original message headers back in next
        while (headerLines.hasMoreElements()) {
            newHeaders.addHeaderLine((String) headerLines.nextElement());
        }
        return newHeaders;
    }
View Full Code Here

Examples of org.apache.james.core.MailHeaders

     */
    public void sendMail( MailAddress sender, Collection recipients, InputStream msg )
            throws MessagingException
    {
        // parse headers
        MailHeaders headers = new MailHeaders( msg );

        // 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

Examples of org.apache.james.core.MailHeaders

     *                            on the spool
     */
    public void sendMail(MailAddress sender, Collection recipients, InputStream msg)
            throws MessagingException {
        // parse headers
        MailHeaders headers = new MailHeaders(msg);

        // 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

Examples of org.apache.james.core.MailHeaders

     *                            on the spool
     */
    public void sendMail(MailAddress sender, Collection recipients, InputStream msg)
            throws MessagingException {
        // parse headers
        MailHeaders headers = new MailHeaders(msg);

        // 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

Examples of org.apache.james.core.MailHeaders

     *                            on the spool
     */
    public void sendMail(MailAddress sender, Collection recipients, InputStream msg)
            throws MessagingException {
        // parse headers
        MailHeaders headers = new MailHeaders(msg);

        // 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
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.