View Javadoc

1   /*****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.james.services;
21  
22  import org.apache.mailet.Mail;
23  import org.apache.mailet.MailAddress;
24  
25  import javax.mail.MessagingException;
26  import javax.mail.internet.MimeMessage;
27  import java.io.InputStream;
28  import java.util.Collection;
29  
30  /***
31   * The interface for Phoenix blocks to the James MailServer
32   *
33   *
34   * @version This is $Revision: 494012 $
35   */
36  public interface MailServer
37  {
38      /***
39       * The component role used by components implementing this service
40       */
41      String ROLE = "org.apache.james.services.MailServer";
42  
43      /***
44       * Reserved user name for the mail delivery agent for multi-user mailboxes
45       */
46      String MDA = "JamesMDA";
47  
48      /***
49       * Reserved user name meaning all users for multi-user mailboxes
50       */
51      String ALL = "AllMailUsers";
52  
53      /***
54       * Pass a MimeMessage to this MailServer for processing
55       *
56       * @param sender - the sender of the message
57       * @param recipients - a Collection of String objects of recipients
58       * @param msg - the MimeMessage of the headers and body content of
59       * the outgoing message
60       * @throws MessagingException - if the message fails to parse
61       * 
62       * @deprecated You can use MailetContext service for this purpose
63       */
64      void sendMail(MailAddress sender, Collection recipients, MimeMessage msg)
65          throws MessagingException;
66  
67      /***
68       * Pass a MimeMessage to this MailServer for processing
69       *
70       * @param sender - the sender of the message
71       * @param recipients - a Collection of String objects of recipients
72       * @param msg - an InputStream containing the headers and body content of
73       * the outgoing message
74       * @throws MessagingException - if the message fails to parse
75       * 
76       * @deprecated You can use MailetContext service for this purpose
77       */
78      void sendMail(MailAddress sender, Collection recipients, InputStream msg)
79          throws MessagingException;
80  
81      /***
82       *  Pass a Mail to this MailServer for processing
83       * @param mail the Mail to be processed
84       * @throws MessagingException
85       */
86      void sendMail(Mail mail)
87          throws MessagingException;
88          
89      /***
90       * Pass a MimeMessage to this MailServer for processing
91       * @param message the message
92       * @throws MessagingException
93       * 
94       * @deprecated You can use MailetContext service for this purpose
95       */
96      void sendMail(MimeMessage message)
97          throws MessagingException;        
98  
99      /***
100      * Retrieve the primary mailbox for userName. For POP3 style stores this
101      * is their (sole) mailbox.
102      *
103      * @param sender - the name of the user
104      * @return a reference to an initialised mailbox
105      */
106     MailRepository getUserInbox(String userName);
107 
108     /***
109      * Generate a new identifier/name for a mail being processed by this server.
110      *
111      * @return the new identifier
112      */
113     String getId();
114 
115     /***
116      * Adds a new user to the mail system with userName. For POP3 style stores
117      * this may only involve adding the user to the UsersStore.
118      *
119      * @param sender - the name of the user
120      * @return a reference to an initialised mailbox
121      * 
122      * @deprecated addUser should not be considered a property of a MailServer
123      * We could have readonly userbases providing full MailServer implementations.
124      * Look at the UsersRepository.addUser(username, password) method.
125      */
126     boolean addUser(String userName, String password);
127 
128     /***
129      * Checks if a server is serviced by mail context
130      *
131      * @param serverName - name of server.
132      * @return true if server is local, i.e. serviced by this mail context
133      */
134     boolean isLocalServer(String serverName);
135 }