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 21 22 package org.apache.james.services; 23 24 import org.apache.mailet.Mail; 25 import org.apache.mailet.MailAddress; 26 27 import javax.mail.MessagingException; 28 import javax.mail.internet.MimeMessage; 29 import java.io.InputStream; 30 import java.util.Collection; 31 32 /** 33 * The interface for Phoenix blocks to the James MailServer 34 * 35 * 36 * @version This is $Revision: 521427 $ 37 */ 38 public interface MailServer 39 { 40 /** 41 * The component role used by components implementing this service 42 */ 43 String ROLE = "org.apache.james.services.MailServer"; 44 45 /** 46 * Reserved user name for the mail delivery agent for multi-user mailboxes 47 */ 48 String MDA = "JamesMDA"; 49 50 /** 51 * Reserved user name meaning all users for multi-user mailboxes 52 */ 53 String ALL = "AllMailUsers"; 54 55 /** 56 * Pass a MimeMessage to this MailServer for processing 57 * 58 * @param sender - the sender of the message 59 * @param recipients - a Collection of String objects of recipients 60 * @param msg - the MimeMessage of the headers and body content of 61 * the outgoing message 62 * @throws MessagingException - if the message fails to parse 63 * 64 * @deprecated You can use MailetContext service for this purpose 65 */ 66 void sendMail(MailAddress sender, Collection recipients, MimeMessage msg) 67 throws MessagingException; 68 69 /** 70 * Pass a MimeMessage to this MailServer for processing 71 * 72 * @param sender - the sender of the message 73 * @param recipients - a Collection of String objects of recipients 74 * @param msg - an InputStream containing the headers and body content of 75 * the outgoing message 76 * @throws MessagingException - if the message fails to parse 77 * 78 * @deprecated You can use MailetContext service for this purpose 79 */ 80 void sendMail(MailAddress sender, Collection recipients, InputStream msg) 81 throws MessagingException; 82 83 /** 84 * Pass a Mail to this MailServer for processing 85 * 86 * @param mail the Mail to be processed 87 * @throws MessagingException 88 */ 89 void sendMail(Mail mail) 90 throws MessagingException; 91 92 /** 93 * Pass a MimeMessage to this MailServer for processing 94 * 95 * @param message the message 96 * @throws MessagingException 97 * 98 * @deprecated You can use MailetContext service for this purpose 99 */ 100 void sendMail(MimeMessage message) 101 throws MessagingException; 102 103 /** 104 * Retrieve the primary mailbox for userName. For POP3 style stores this 105 * is their (sole) mailbox. 106 * 107 * @param userName - the name of the user 108 * @return a reference to an initialised mailbox 109 */ 110 MailRepository getUserInbox(String userName); 111 112 /** 113 * Generate a new identifier/name for a mail being processed by this server. 114 * 115 * @return the new identifier 116 */ 117 String getId(); 118 119 /** 120 * Adds a new user to the mail system with userName. For POP3 style stores 121 * this may only involve adding the user to the UsersStore. 122 * 123 * @param userName - the name of the user 124 * @return a reference to an initialised mailbox 125 * 126 * @deprecated addUser should not be considered a property of a MailServer 127 * We could have readonly userbases providing full MailServer implementations. 128 * Look at the UsersRepository.addUser(username, password) method. 129 */ 130 boolean addUser(String userName, String password); 131 132 /** 133 * Checks if a server is serviced by mail context 134 * 135 * @param serverName - name of server. 136 * @return true if server is local, i.e. serviced by this mail context 137 */ 138 boolean isLocalServer(String serverName); 139 140 /** 141 * Return true if virtualHosting support is enabled, otherwise false 142 * 143 * @return true or false 144 */ 145 boolean supportVirtualHosting(); 146 147 /** 148 * Return the default domain which will get used to deliver mail to if only the localpart 149 * was given on rcpt to. 150 * 151 * @return the defaultdomain 152 */ 153 String getDefaultDomain(); 154 155 /** 156 * Return the helloName which should use for all services by default 157 * 158 * @return the helloName 159 */ 160 String getHelloName(); 161 }