Package org.apache.mailet

Examples of org.apache.mailet.MailAddress


     * @throws MessagingException if an exception is caught while placing the mail
     *                            on the spool
     */
    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

            if ( enableAliases && user.getAliasing() ) {
                username = user.getAlias();
            }
            // Forwarding takes precedence over local aliases
            if ( enableForwarding && user.getForwarding() ) {
                MailAddress forwardTo = user.getForwardingDestination();
                if ( forwardTo == null ) {
                    StringBuffer errorBuffer =
                            new StringBuffer( 128 )
                            .append( "Forwarding was enabled for " )
                            .append( username )
                            .append( " but no forwarding address was set for this account." );
                    throw new MessagingException( errorBuffer.toString() );
                }
                Collection recipients = new HashSet();
                recipients.add( forwardTo );
                try {
                    sendMail( sender, recipients, message );
                    if ( getLogger().isInfoEnabled() ) {
                        StringBuffer logBuffer =
                                new StringBuffer( 128 )
                                .append( "Mail for " )
                                .append( username )
                                .append( " forwarded to " )
                                .append( forwardTo.toString() );
                        getLogger().info( logBuffer.toString() );
                    }
                    return;
                }
                catch ( MessagingException me ) {
                    if ( getLogger().isErrorEnabled() ) {
                        StringBuffer logBuffer =
                                new StringBuffer( 128 )
                                .append( "Error forwarding mail to " )
                                .append( forwardTo.toString() )
                                .append( "attempting local delivery" );
                        getLogger().error( logBuffer.toString() );
                    }
                    throw me;
                }
View Full Code Here

                }
            }
            // if we found a suitable domain, use it.  Otherwise fallback to the host name.
            postMasterAddress = postMasterAddress + "@" + (domainName != null ? domainName : hostName);
        }
        this.postmaster = new MailAddress( postMasterAddress );
        context.put( Constants.POSTMASTER, postmaster );

        if (!isLocalServer(postmaster.getHost())) {
            StringBuffer warnBuffer
                = new StringBuffer(320)
View Full Code Here

     *
     * @throws MessagingException if an exception is caught while placing the mail
     *                            on the spool
     */
    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

        reply.setHeader(RFC2822Headers.RETURN_PATH,"<>");
        //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

            if (enableAliases && user.getAliasing()) {
                username = user.getAlias();
            }
            // Forwarding takes precedence over local aliases
            if (enableForwarding && user.getForwarding()) {
                MailAddress forwardTo = user.getForwardingDestination();
                if (forwardTo == null) {
                    StringBuffer errorBuffer =
                        new StringBuffer(128)
                            .append("Forwarding was enabled for ")
                            .append(username)
                            .append(" but no forwarding address was set for this account.");
                    throw new MessagingException(errorBuffer.toString());
                }
                Collection recipients = new HashSet();
                recipients.add(forwardTo);
                try {
                    sendMail(sender, recipients, message);
                    if (getLogger().isInfoEnabled()) {
                        StringBuffer logBuffer =
                            new StringBuffer(128)
                                    .append("Mail for ")
                                    .append(username)
                                    .append(" forwarded to ")
                                    .append(forwardTo.toString());
                        getLogger().info(logBuffer.toString());
                    }
                    return;
                } catch (MessagingException me) {
                    if (getLogger().isErrorEnabled()) {
                        StringBuffer logBuffer =
                            new StringBuffer(128)
                                    .append("Error forwarding mail to ")
                                    .append(forwardTo.toString())
                                    .append("attempting local delivery");
                        getLogger().error(logBuffer.toString());
                    }
                    throw me;
                }
View Full Code Here

            out.flush();
            return true;
        }
        JamesUser user = (JamesUser)baseuser;
        // Verify 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);
            out.flush();
            return true;
        }

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

     */
    public MailImpl(MimeMessage message) throws MessagingException {
        this();
        Address[] addresses;
        addresses = message.getFrom();
        MailAddress sender = new MailAddress(new InternetAddress(addresses[0].toString()));
        Collection recipients = new ArrayList();
        addresses = message.getRecipients(MimeMessage.RecipientType.TO);
        for (int i = 0; i < addresses.length; i++) {
            recipients.add(new MailAddress(new InternetAddress(addresses[i].toString())));
        }
        this.name = message.toString();
        this.sender = sender;
        this.recipients = recipients;
        this.setMessage(message);
View Full Code Here

        reply.setFrom(new InternetAddress(getRecipients().iterator().next().toString()));
        reply.setText(bounceText);
        reply.setHeader(RFC2822Headers.MESSAGE_ID, "replyTo-" + getName());
        return new MailImpl(
            "replyTo-" + getName(),
            new MailAddress(getRecipients().iterator().next().toString()),
            recipients,
            reply);
    }
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.