Examples of MailAddress


Examples of org.apache.mailet.MailAddress

            iart[0] = replyTo.toInternetAddress();
            reply.setReplyTo(iart);
        }
        if(sender == null) {
            reply.setHeader(RFC2822Headers.FROM, message.getHeader(RFC2822Headers.FROM, ","));
            sender = new MailAddress(((InternetAddress)message.getFrom()[0]).getAddress());
        } else {
            reply.setFrom(sender.toInternetAddress());
        }
        //Send it off...
        getMailetContext().sendMail(sender, recipients, reply);
View Full Code Here

Examples of org.apache.mailet.MailAddress

        Collection recipientsToRemove = null;
        MailetContext mailetContext = getMailetContext();
        boolean postmasterAddressed = false;

        for (Iterator i = recipients.iterator(); i.hasNext(); ) {
            MailAddress addr = (MailAddress)i.next();
            if (addr.getUser().equalsIgnoreCase("postmaster") &&
                mailetContext.isLocalServer(addr.getHost())) {
                //Should remove this address... we want to replace it with
                //  the server's postmaster address
                if (recipientsToRemove == null) {
                    recipientsToRemove = new Vector();
                }
View Full Code Here

Examples of org.apache.mailet.MailAddress

     */
    public void service(Mail mail) throws MessagingException {
        Collection recipients = mail.getRecipients();
        Collection errors = new Vector();
        for (Iterator i = recipients.iterator(); i.hasNext(); ) {
            MailAddress recipient = (MailAddress) i.next();
            try {
                getMailetContext().storeMail(mail.getSender(), recipient, mail.getMessage());
            } catch (Exception ex) {
                getMailetContext().log("Error while storing mail.", ex);
                errors.add(recipient);
View Full Code Here

Examples of org.apache.mailet.MailAddress

            mappingStmt = conn.prepareStatement(query);


            for (Iterator i = recipients.iterator(); i.hasNext(); ) {
                try {
                    MailAddress source = (MailAddress)i.next();
                    mappingStmt.setString(1, source.toString());
                    mappingRS = mappingStmt.executeQuery();
                    if (!mappingRS.next()) {
                        //This address was not found
                        continue;
                    }
                    try {
                        String targetString = mappingRS.getString(1);
                        MailAddress target = new MailAddress(targetString);

                        //Mark this source address as an address to remove from the recipient list
                        recipientsToRemove.add(source);
                        recipientsToAdd.add(target);
                    } catch (ParseException pe) {
View Full Code Here

Examples of org.apache.mailet.MailAddress

            MimeMessage message = new MimeMessage(mail.getMessage());
            //We need to remove this header from the copy we're sending around
            message.removeHeader(RFC2822Headers.RETURN_PATH);

            //Figure out the listserv address.
            MailAddress listservAddr = getListservAddress();
            if (listservAddr == null) {
                //Use the recipient
                listservAddr = (MailAddress)mail.getRecipients().iterator().next();
            }

            //Check if the X-been-there header is set to the listserv's name
            //  (the address).  If it has, this means it's a message from this
            //  listserv that's getting bounced back, so we need to swallow it
            if (listservAddr.equals(message.getHeader("X-been-there"))) {
                mail.setState(Mail.GHOST);
                return;
            }

            //Set the subject if set
            String prefix = getSubjectPrefix();
            if (prefix != null) {
                if (isPrefixAutoBracketed()) {
                    StringBuffer prefixBuffer =
                        new StringBuffer(64)
                            .append("[")
                            .append(prefix)
                            .append("]");
                    prefix = prefixBuffer.toString();
                }
                String subj = message.getSubject();
                if (subj == null) {
                    subj = "";
                }
                subj = normalizeSubject(subj, prefix);
                message.setSubject(subj);
            }

            //If replies should go to this list, we need to set the header
            if (isReplyToList()) {
                message.setHeader(RFC2822Headers.REPLY_TO, listservAddr.toString());
            }
            //We're going to set this special header to avoid bounces
            //  getting sent back out to the list
            message.setHeader("X-been-there", listservAddr.toString());

            //Send the message to the list members
            //We set the postmaster as the sender for now so bounces go to him/her
            getMailetContext().sendMail(getMailetContext().getPostmaster(), members, message);
View Full Code Here

Examples of org.apache.mailet.MailAddress

                rs = stmt.executeQuery();
                Collection tmpMembers = new Vector();
                while (rs.next()) {
                    String address = rs.getString(1);
                    try {
                        MailAddress mailAddress = new MailAddress(address);
                        tmpMembers.add(mailAddress);
                    } catch (ParseException pe) {
                        //don't stop... just log and continue
                        StringBuffer exceptionBuffer =
                            new StringBuffer(64)
                                    .append("error parsing address '")
                                    .append(address)
                                    .append("' in listserv '")
                                    .append(listservID)
                                    .append("'");
                        log(exceptionBuffer.toString());
                    }
                }
                members = tmpMembers;
            } finally {
                ResultSet localRS = rs;
                // Clear reference to result set
                rs = null;
                theJDBCUtil.closeJDBCResultSet(localRS);
                Statement localStmt = stmt;
                // Clear reference to statement
                stmt = null;
                theJDBCUtil.closeJDBCStatement(localStmt);
            }

            stmt = conn.prepareStatement(listservQuery);
            stmt.setString(1, listservID);
            rs = stmt.executeQuery();
            if (!rs.next()) {
                StringBuffer exceptionBuffer =
                    new StringBuffer(64)
                            .append("Could not find listserv record for '")
                            .append(listservID)
                            .append("'");
                throw new MailetException(exceptionBuffer.toString());
            }
            membersOnly = rs.getBoolean("members_only");
            attachmentsAllowed = rs.getBoolean("attachments_allowed");
            replyToList = rs.getBoolean("reply_to_list");
            subjectPrefix = rs.getString("subject_prefix");
            String address = rs.getString("list_address");
            if (address == null) {
                listservAddress = null;
            } else {
                try {
                    listservAddress = new MailAddress(address);
                } catch (ParseException pe) {
                    //log and ignore
                    StringBuffer logBuffer =
                        new StringBuffer(128)
                                .append("invalid listserv address '")
View Full Code Here

Examples of org.apache.mailet.MailAddress

                    addressString = st.nextToken();
                    iAddress = new InternetAddress(addressString);
                    if (isDebug) {
                        log("Address = " + iAddress.toString());
                    }
                    addresses.add(new MailAddress(iAddress));
                }
            }
        }
        return addresses;
    }
View Full Code Here

Examples of org.apache.mailet.MailAddress

                            .append(": did not start and end with < >");
                    getLogger().error(errorBuffer.toString());
                }
                return;
            }
            MailAddress senderAddress = null;
            //Remove < and >
            sender = sender.substring(1, sender.length() - 1);
            if (sender.length() == 0) {
                //This is the <> case.  Let senderAddress == null
            } else {
                if (sender.indexOf("@") < 0) {
                    sender = sender + "@localhost";
                }
                try {
                    senderAddress = new MailAddress(sender);
                } catch (Exception pe) {
                    responseString = "501 Syntax error in sender address";
                    writeLoggedFlushedResponse(responseString);
                    if (getLogger().isErrorEnabled()) {
                        StringBuffer errorBuffer =
View Full Code Here

Examples of org.apache.mailet.MailAddress

                                .append(": did not start and end with < >");
                    getLogger().error(errorBuffer.toString());
                }
                return;
            }
            MailAddress recipientAddress = null;
            //Remove < and >
            recipient = recipient.substring(1, recipient.length() - 1);
            if (recipient.indexOf("@") < 0) {
                recipient = recipient + "@localhost";
            }
            try {
                recipientAddress = new MailAddress(recipient);
            } catch (Exception pe) {
                responseString = "501 Syntax error in recipient address";
                writeLoggedFlushedResponse(responseString);

                if (getLogger().isErrorEnabled()) {
                    StringBuffer errorBuffer =
                        new StringBuffer(192)
                                .append("Error parsing recipient address: ")
                                .append(recipient)
                                .append(": ")
                                .append(pe.getMessage());
                    getLogger().error(errorBuffer.toString());
                }
                return;
            }
            if (theConfigData.isAuthRequired()) {
                // Make sure the mail is being sent locally if not
                // authenticated else reject.
                if (getUser() == null) {
                    String toDomain = recipientAddress.getHost();
                    if (!theConfigData.getMailServer().isLocalServer(toDomain)) {
                        responseString = "530 Authentication Required";
                        writeLoggedFlushedResponse(responseString);
                        getLogger().error("Rejected message - authentication is required for mail request");
                        return;
                    }
                } else {
                    // Identity verification checking
                    if (theConfigData.isVerifyIdentity()) {
                        String authUser = (getUser()).toLowerCase(Locale.US);
                        MailAddress senderAddress = (MailAddress) state.get(SENDER);
                        boolean domainExists = false;

                        if ((!authUser.equals(senderAddress.getUser())) ||
                            (!theConfigData.getMailServer().isLocalServer(senderAddress.getHost()))) {
                            responseString = "503 Incorrect Authentication for Specified Email Address";
                            writeLoggedFlushedResponse(responseString);
                            if (getLogger().isErrorEnabled()) {
                                StringBuffer errorBuffer =
                                    new StringBuffer(128)
View Full Code Here

Examples of org.apache.mailet.MailAddress

            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));
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.