Package org.apache.mailet

Examples of org.apache.mailet.MailAddress


    public void init() throws javax.mail.MessagingException {
        StringTokenizer st = new StringTokenizer(getCondition(), ", \t", false);
        recipients = new HashSet();
        while (st.hasMoreTokens()) {
            recipients.add(new MailAddress(st.nextToken()));
        }
    }
View Full Code Here


        context.put(Constants.SERVER_NAMES, this.serverNames);


        // Get postmaster
        String postMasterAddress = conf.getChild("postmaster").getValue("root@localhost");
        this.postmaster = new MailAddress( postMasterAddress );
        context.put( Constants.POSTMASTER, postmaster );

        Configuration userNamesConf = conf.getChild("usernames");
        if (userNamesConf.getAttribute("ignoreCase").equals("TRUE")) {
            ignoreCase = true;
View Full Code Here

        System.out.println(VERSION);
        getLogger().info("JAMES ...init end");
    }

    public void sendMail(MimeMessage message) throws MessagingException {
        MailAddress sender = new MailAddress((InternetAddress)message.getFrom()[0]);
        Collection recipients = new HashSet();
        Address addresses[] = message.getAllRecipients();
        for (int i = 0; i < addresses.length; i++) {
            recipients.add(new MailAddress((InternetAddress)addresses[i]));
        }
        sendMail(sender, recipients, message);
    }
View Full Code Here

        MimeMessage reply = (MimeMessage) orig.reply(false);
        //Create the list of recipients in our MailAddress format
        Collection recipients = new HashSet();
        Address addresses[] = reply.getAllRecipients();
        for (int i = 0; i < addresses.length; i++) {
            recipients.add(new MailAddress((InternetAddress)addresses[i]));
        }
        //Change the sender...
        reply.setFrom(bouncer.toInternetAddress());
        try {
            //Create the message body
View Full Code Here

            user = (JamesUser) localusers.getUserByName(username);
            if (enableAliases && user.getAliasing()) {
                username = user.getAlias();
            }
            if (enableForwarding && user.getForwarding()) {
                MailAddress forwardTo = user.getForwardingDestination();
                Collection recipients = new HashSet();
                recipients.add(forwardTo);
                try {
                    sendMail(sender, recipients, message);
                    getLogger().info("Mail for " + username + " forwarded to "
                                         +  forwardTo.toString());
                    return;
                } catch (MessagingException me) {
                    getLogger().error("Error forwarding mail to "
                              + forwardTo.toString()
                              + "attempting local delivery");
                }
            }
        }
View Full Code Here

public class CommandForListserv extends GenericRecipientMatcher {

    private MailAddress listservAddress;

    public void init() throws MessagingException {
        listservAddress = new MailAddress(getCondition());
    }
View Full Code Here

            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
                    log("error parsing address '" + address + "' in listserv '" + listservID + "'");
                }
            }
            members = tmpMembers;
            rs.close();
            stmt.close();

            stmt = conn.prepareStatement(listservQuery);
            stmt.setString(1, listservID);
            rs = stmt.executeQuery();
            if (!rs.next()) {
                throw new MailetException("Could not find listserv record for '" + listservID + "'");
            }
            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
                    log("invalid listserv address '" + listservAddress + "' for listserv '" + listservID + "'");
                    listservAddress = null;
                }
View Full Code Here

                out.println("Can't set forwarding for this user type.");
                return true;
            }
            JamesUser user = (JamesUser)baseuser;
        // Veriy acceptable email address
        MailAddress forwardAddr;
            try {
                 forwardAddr = new MailAddress(forward);
            } catch(ParseException pe) {
        out.println("Parse exception with that email address: "
                            + pe.getMessage());
        out.println("Forwarding address not added for " + username);
            return true;
        }

        boolean success;
        success = user.setForwardingDestination(forwardAddr);
        if (success){
            user.setForwarding(true);
        users.updateUser(user);
                out.println("Forwarding destination for " + username
                             + " set to:" + forwardAddr.toString());
                getLogger().info("Forwarding destination for " + username
                                 + " set to:" + forwardAddr.toString());
        } else {
                out.println("Error setting forwarding");
                getLogger().info("Error setting forwarding");
        }
            out.flush();
View Full Code Here

    public final void service(Mail mail) throws MessagingException {
        if (mail.getRecipients().size() != 1) {
            getMailetContext().bounce(mail, "You can only send one command at a time to this listserv manager.");
            return;
        }
        MailAddress address = (MailAddress)mail.getRecipients().iterator().next();
        if (address.getUser().endsWith("-off")) {
            if (existsAddress(mail.getSender())) {
                if (removeAddress(mail.getSender())) {
                    getMailetContext().bounce(mail, "Successfully removed from listserv.");
                } else {
                    getMailetContext().bounce(mail, "You are not subscribed to this listserv.");
                }
            } else {
                getMailetContext().bounce(mail, "Unable to remove you from listserv for some reason");
            }
        } else if (address.getUser().endsWith("-on")) {
            if (existsAddress(mail.getSender())) {
                getMailetContext().bounce(mail, "You are already subscribed to this listserv.");
            } else {
                if (addAddress(mail.getSender())) {
                    getMailetContext().bounce(mail, "Successfully added to listserv.");
View Full Code Here

        boolean useForwarding = rsUsers.getBoolean(4);
        String forwardingDestination = rsUsers.getString(5);
        boolean useAlias = rsUsers.getBoolean(6);
        String alias = rsUsers.getString(7);

        MailAddress forwardAddress = null;
        if ( forwardingDestination != null ) {
            try {
                forwardAddress = new MailAddress(forwardingDestination);
            }
            catch (javax.mail.internet.ParseException pe) {
                throw new RuntimeException(
                    "Invalid mail address in database: " + forwardingDestination +
                    ", for user " + username + ".");
View Full Code Here

TOP

Related Classes of org.apache.mailet.MailAddress

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.