Package org.apache.mailet

Examples of org.apache.mailet.MailAddress


        assertNotNull("Should match all recipients", inverter.match(mail));
    }
   
    public void testNonMatch() throws MessagingException {
        final MailAddress address1 = new MailAddress("user", "domain");
        final MailAddress address2 = new MailAddress("user", "domain2");
       
        MatcherInverter inverter = new MatcherInverter(new GenericMatcher() {

            public Collection match(Mail mail) throws MessagingException {
                return mail.getRecipients();
View Full Code Here


        assertNull("Should match all recipients", inverter.match(mail));
    }
   
    public void testOneMatch() throws MessagingException {
        final MailAddress address1 = new MailAddress("user", "domain");
        final MailAddress address2 = new MailAddress("user", "domain2");
       
        MatcherInverter inverter = new MatcherInverter(new GenericMatcher() {

            public Collection match(Mail mail) throws MessagingException {
                return Arrays.asList(new MailAddress[] {address1});
            }
        });
        FakeMail mail = new FakeMail();
        mail.setRecipients(Arrays.asList(new MailAddress[] { address1, address2 }));

        assertEquals("Should match one recipient", address2.toString(), inverter.match(mail).iterator().next().toString());
    }
View Full Code Here

        LMTPMultiResponse mResponse = null;

        Iterator<MailAddress> recipients = mail.getRecipients().iterator();
       
        while (recipients.hasNext()) {
            MailAddress recipient = recipients.next();
            Response response = null;
            for (DeliverToRecipientHook handler: handlers) {
                response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(handler.deliver(session, recipient, mail));
                if (response != null) {
                    break;
View Full Code Here

            Collection tmpMembers = new Vector();
            while (rs.next()) {
                String address = rs.getString(1);
                System.out.println(address);
                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 '" + listservAddress + "'");
                }
            }
            members = tmpMembers;
            rs.close();
            stmt.close();
            stmt = conn.prepareStatement(listservQuery);
            stmt.setString(1, listservAddress.toString());
            rs = stmt.executeQuery();
            if (!rs.next()) {
                throw new MailetException("Could not find listserv record for '" + listservAddress + "'");
            }
            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 '" + listservAddress + "'");
                    listservAddress = null;
                }
View Full Code Here

        rsTables.close();
        return found;
    }
    private MailAddress getListAddress(Mail mail){
      for (Iterator i = mail.getRecipients().iterator(); i.hasNext(); ) {
            MailAddress rec = (MailAddress) i.next();
            if (matchRecipient(rec)) {
                //yes I know.. this will prevent cross postings, is that so bad? :-)
                return rec;
            }
        }
View Full Code Here

        Collection newRecipients = new HashSet();
        String addressList = getInitParameter("recipients")==null? getInitParameter("to"):getInitParameter("recipients");
        StringTokenizer st = new StringTokenizer(addressList, ",", false);
        while (st.hasMoreTokens()) {
            try{
                newRecipients.add(new MailAddress(st.nextToken()));
            }catch(Exception e){
                log("add recipient failed in getRecipients");
            }
        }
View Full Code Here

* returns the senders address, as a MailAddress
*/
     public MailAddress getSender(){
         String sr = getInitParameter("sender");
        if(sr != null){
            MailAddress rv;
            if(sr.compareTo("postmaster")==0){
                rv = getMailetContext().getPostmaster();
                return rv;
            }
            if(sr.compareTo("sender")==0){
                return null;
            }
            try{
                rv = new MailAddress(sr);
                return rv;
            }catch(Exception e){
                log("Parse error in getSender "+sr);
            }
         }
View Full Code Here

* return the reply to address as a string
*/
public MailAddress getReplyTo(){
         String sr = getInitParameter("replyto");
        if(sr != null){
            MailAddress rv;
            if(sr.compareTo("postmaster")==0){
                rv = getMailetContext().getPostmaster();
                return rv;
            }
            if(sr.compareTo("sender")==0){
                return null;
            }
            try{
                rv = new MailAddress(sr);
                return rv;
            }catch(Exception e){
                log("Parse error in getReplyTo "+sr);
            }
         }
View Full Code Here

    public void init() throws MessagingException {
        if (getInitParameter("sendingAddress") == null) {
            notifier = getMailetContext().getPostmaster();
        } else {
            notifier = new MailAddress(getInitParameter("sendingAddress"));
        }
        if (getInitParameter("notice") == null) {
            noticeText = "We were unable to deliver the attached message because of an error in the mail server.";
        } else {
            noticeText = getInitParameter("notice");
View Full Code Here

        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

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.