001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.services;
019:
020: import org.apache.mailet.Mail;
021: import org.apache.mailet.MailAddress;
022:
023: import javax.mail.MessagingException;
024: import javax.mail.internet.MimeMessage;
025: import java.io.InputStream;
026: import java.util.Collection;
027:
028: /**
029: * The interface for Phoenix blocks to the James MailServer
030: *
031: *
032: * @version This is $Revision: 494012 $
033: */
034: public interface MailServer {
035: /**
036: * The component role used by components implementing this service
037: */
038: String ROLE = "org.apache.james.services.MailServer";
039:
040: /**
041: * Reserved user name for the mail delivery agent for multi-user mailboxes
042: */
043: String MDA = "JamesMDA";
044:
045: /**
046: * Reserved user name meaning all users for multi-user mailboxes
047: */
048: String ALL = "AllMailUsers";
049:
050: /**
051: * Pass a MimeMessage to this MailServer for processing
052: *
053: * @param sender - the sender of the message
054: * @param recipients - a Collection of String objects of recipients
055: * @param msg - the MimeMessage of the headers and body content of
056: * the outgoing message
057: * @throws MessagingException - if the message fails to parse
058: *
059: * @deprecated You can use MailetContext service for this purpose
060: */
061: void sendMail(MailAddress sender, Collection recipients,
062: MimeMessage msg) throws MessagingException;
063:
064: /**
065: * Pass a MimeMessage to this MailServer for processing
066: *
067: * @param sender - the sender of the message
068: * @param recipients - a Collection of String objects of recipients
069: * @param msg - an InputStream containing the headers and body content of
070: * the outgoing message
071: * @throws MessagingException - if the message fails to parse
072: *
073: * @deprecated You can use MailetContext service for this purpose
074: */
075: void sendMail(MailAddress sender, Collection recipients,
076: InputStream msg) throws MessagingException;
077:
078: /**
079: * Pass a Mail to this MailServer for processing
080: * @param mail the Mail to be processed
081: * @throws MessagingException
082: */
083: void sendMail(Mail mail) throws MessagingException;
084:
085: /**
086: * Pass a MimeMessage to this MailServer for processing
087: * @param message the message
088: * @throws MessagingException
089: *
090: * @deprecated You can use MailetContext service for this purpose
091: */
092: void sendMail(MimeMessage message) throws MessagingException;
093:
094: /**
095: * Retrieve the primary mailbox for userName. For POP3 style stores this
096: * is their (sole) mailbox.
097: *
098: * @param sender - the name of the user
099: * @return a reference to an initialised mailbox
100: */
101: MailRepository getUserInbox(String userName);
102:
103: /**
104: * Generate a new identifier/name for a mail being processed by this server.
105: *
106: * @return the new identifier
107: */
108: String getId();
109:
110: /**
111: * Adds a new user to the mail system with userName. For POP3 style stores
112: * this may only involve adding the user to the UsersStore.
113: *
114: * @param sender - the name of the user
115: * @return a reference to an initialised mailbox
116: *
117: * @deprecated addUser should not be considered a property of a MailServer
118: * We could have readonly userbases providing full MailServer implementations.
119: * Look at the UsersRepository.addUser(username, password) method.
120: */
121: boolean addUser(String userName, String password);
122:
123: /**
124: * Checks if a server is serviced by mail context
125: *
126: * @param serverName - name of server.
127: * @return true if server is local, i.e. serviced by this mail context
128: */
129: boolean isLocalServer(String serverName);
130: }
|