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