Package org.apache.mailet

Examples of org.apache.mailet.MailAddress


        attributes.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");
        ignoreCase = userNamesConf.getAttributeAsBoolean("ignoreCase", false);
        enableAliases = userNamesConf.getAttributeAsBoolean("enableAliases", false);
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

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

        try {
            Object obj = in.readObject();
            if (obj == null) {
                sender = null;
            } else if (obj instanceof String) {
                sender = new MailAddress((String)obj);
            } else if (obj instanceof MailAddress) {
                sender = (MailAddress)obj;
            }
        } catch (ParseException pe) {
            throw new IOException("Error parsing sender address: " + pe.getMessage());
View Full Code Here

        reply.setRecipients(Message.RecipientType.TO, addr);
        reply.setFrom(new InternetAddress(getRecipients().iterator().next().toString()));
        reply.setText(message);
        reply.setHeader("Message-Id", "replyTo-" + getName());

        return new MailImpl("replyTo-" + getName(), new MailAddress(getRecipients().iterator().next().toString()), recipients, reply);
    }
View Full Code Here

                out.println("501 Syntax error in parameters or arguments");
                getLogger().error("Error parsing sender address: " + sender
                                  + ": did not start and end with < >");
                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) {
                    out.println("501 Syntax error in parameters or arguments");
                    getLogger().error("Error parsing sender address: " + sender
                                      + ": " + pe.getMessage());
                    return;
View Full Code Here

                getLogger().error("Error parsing recipient address: "
                                  + recipient
                                  + ": did not start and end with < >");
                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) {
                out.println("501 Syntax error in parameters or arguments");
                getLogger().error("Error parsing recipient address: "
                                  + recipient + ": " + pe.getMessage());
                return;
            }
            // If this is a delivery failure notification (MAIL FROM: <>)
            //   we don't enforce authentication
            if (authRequired && state.get(SENDER) != null) {
                // Make sure the mail is being sent locally if not
                // authenticated else reject.

                if (!state.containsKey(AUTH)) {
                    String toDomain = recipientAddress.getHost();

                    if (!mailServer.isLocalServer(toDomain)) {
                        out.println("530 Authentication Required");
                        getLogger().error(
                            "Authentication is required for mail request");
                        return;
                    }
                } else {
                    // Identity verification checking
                    if (verifyIdentity) {
                        String authUser = (String)state.get(AUTH);
                        MailAddress senderAddress
                                = (MailAddress)state.get(SENDER);
                        boolean domainExists = false;

                        if (!authUser.equalsIgnoreCase(
                                senderAddress.getUser())) {
                        out.println("503 Incorrect Authentication for Specified Email Address");
                        getLogger().error("User " + authUser
                                + " authenticated, however tried sending email as "
                                + senderAddress);
                        return;
                    }
                    if (!mailServer.isLocalServer(
                                       senderAddress.getHost())) {
                        out.println("503 Incorrect Authentication for Specified Email Address");
                        getLogger().error("User " + authUser
                            + " authenticated, however tried sending email as "
                            + senderAddress);
                            return;
View Full Code Here

            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

        JamesUser user = (JamesUser)users.getUserByName(username);
        if (user == null) {
            getLogger().error("No such user " + username + " found!");
            throw new RemoteException("No such user " + username + " found!");
        }
        MailAddress forwardAddress;
        try {
            forwardAddress = new MailAddress(forward);
        } catch (ParseException pe) {
            getLogger().error("Parse exception with that email address: " + pe.getMessage());
            throw new RemoteException("Parse exception with that email address: " + pe.getMessage());
        }
        if (user.setForwardingDestination(forwardAddress)) {
            user.setForwarding(true);
            users.updateUser(user);
            getLogger().info("Forwarding destination for " + username + " set to: " + forwardAddress.toString());
            return true;
        }
        getLogger().error("Error setting forward for user " + username);
        return false;
    }
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.