1 package org.sourceforge.vlibrary.user.workers; 2 3 import javax.mail.Session; 4 5 import org.springframework.mail.MailException; 6 import org.springframework.mail.SimpleMailMessage; 7 8 /** 9 * Simple SMTP Mime message sender. 10 * 11 * @version $Revision$ $Date$ 12 * 13 */ 14 public interface MailSender { 15 16 /** 17 * Gets the SMTP user password. 18 * 19 * @return the password 20 */ 21 String getPassword(); 22 23 /** 24 * Sets the password and forces reinitialization of the authenticated 25 * mail session if the session is authenticated. 26 * 27 * @param password new value for the password 28 */ 29 void setPassword(String password); 30 31 /** 32 * Returns the smtp user name. 33 * 34 * @return the username 35 */ 36 String getUser(); 37 38 /** 39 * Sets the smpt user name and forces reinitialization of the authenticated 40 * mail session if the session is authenticated. 41 * 42 * @param user new value for the user name 43 */ 44 void setUser(String user); 45 46 /** 47 * Gets an smtp session with the currently configured properties, creating 48 * a new session if the session has not been initialized. 49 * 50 * @return smtp session 51 */ 52 Session getSession(); 53 54 /** 55 * Sets the smtp session and modifies bean properties to match those of 56 * the given session. 57 * 58 * @param session the new session 59 */ 60 void setSession(Session session); 61 62 /** 63 * Gets the smpt host name. Default value is <code>localhost</code>. 64 * 65 * @return smpt host 66 */ 67 String getHost(); 68 69 /** 70 * Sets the smtp host name. 71 * 72 * @param host the new smtp host name 73 */ 74 void setHost(String host); 75 76 /** 77 * Gets the smtp port. Default value is <code>25</code>. 78 * 79 * @return the smpt port 80 */ 81 int getPort(); 82 83 /** 84 * Sets the smpt port. 85 * 86 * @param port the new smtp port 87 */ 88 void setPort(int port); 89 90 /** 91 * Gets authentication state of underlying mail session. Default value is 92 * <code>false</code>. 93 * 94 * @return true means mail session is authenticated 95 */ 96 boolean isAuthenticated(); 97 98 /** 99 * Sets authentication state of underlying mail session. 100 * 101 * @param authenticated new value for session authentication property 102 */ 103 void setAuthenticated(boolean authenticated); 104 105 /** 106 * Whether or not TLS is used to connect to the SMTP server. Default value is 107 * <code>false</code>. 108 * 109 * @return true means TLS transport is used 110 */ 111 boolean isTls(); 112 113 /** 114 * Gets TLS state of underlying mail session. 115 * 116 * @param tls new value for TLS transport property 117 */ 118 void setTls(boolean tls); 119 120 /** 121 * Sends a mail message using an smtp session with properties matching 122 * the current bean property values. 123 * 124 * @param message message to send 125 * @throws MailException if a messsaging exception occurs sending 126 * the message 127 */ 128 void send(SimpleMailMessage message) throws MailException; 129 130 /** 131 * Sends an array of mail message using an smtp session with properties 132 * matching the current bean property values. 133 * 134 * @param messages messages to send 135 * @throws MailException if a messsaging exception occurs 136 */ 137 void send(SimpleMailMessage[] messages) throws MailException; 138 139 }