ejel
Class EmailAccount

java.lang.Object
  extended by ejel.EmailAccount

public class EmailAccount
extends java.lang.Object

Represents an email account to be used to send emails via an SMTP Server


Nested Class Summary
static class EmailAccount.ServerProtocol
          The server protocol used to connect and communicate with the server
 
Field Summary
static int EMAILS_PER_HOUR_NO_LIMIT
          SMTP Server is always ready for sending new emails using this account
static java.lang.String SMTP_REGEX
          A regex expression to validate smtp servers addresses
 
Constructor Summary
EmailAccount(java.lang.String csvLine)
          Constructs a new EmailAccount object
EmailAccount(java.lang.String login, java.lang.String pswd, java.lang.String srvr, int port, boolean ssl, boolean auth, int emailsPerH, boolean monoCon)
          Constructs a new EmailAccount object
EmailAccount(java.lang.String login, java.lang.String pswd, java.lang.String srvr, int port, boolean ssl, EmailAccount.ServerProtocol protocol)
          Constructs a new EmailAccount object.
EmailAccount(java.lang.String login, java.lang.String pswd, java.lang.String srvr, java.lang.String port, java.lang.String ssl, java.lang.String auth, java.lang.String emailsPerH, java.lang.String monoCon)
          Constructs a new EmailAccount object
 
Method Summary
 int getEmailsPerHour()
          Get the number of emails to send per one hour
 java.lang.String getHost()
          Gets the host of the server
 long getLastSendTimeMillis()
          Get the last time (millis) when the last email was sent
 java.lang.String getLogin()
          Get the user login of the email account
 java.lang.String getPassword()
          Get the password of the email account
 int getPortNumber()
          Get the default port number of the SMTP Server for the email account
 EmailAccount.ServerProtocol getServerProtocol()
          Gets the identifier of the protocol used to connect to the server
 java.lang.String getSmtpServer()
          Get the SMTP Server address for the email account
 boolean isBusy()
          Gets true if the email account is busy i.e sending an email
 boolean isDisabled()
          Gets true if the email account is disabled
 boolean isReadyForSendingNewEmail()
          Gets true if the email account is ready to send an other email via the SMTP Server
 java.lang.Boolean needAuthentication()
          Gets true if the SMTP Server needs user authentication
 java.lang.Boolean needSSL()
          Returns true if the connection with SMTP Server is secured
 boolean setBusyStatus(boolean busy)
          Sets on the busy status or off
 void setDisabled()
          Set the email account status to disabled
 void setReadyForSendingNewEmail()
          Sets the ready status of the email account.
 void updateLastSendTimeMillis()
          Set last time (millis) when last email was sent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SMTP_REGEX

public static final java.lang.String SMTP_REGEX
A regex expression to validate smtp servers addresses

See Also:
Constant Field Values

EMAILS_PER_HOUR_NO_LIMIT

public static final int EMAILS_PER_HOUR_NO_LIMIT
SMTP Server is always ready for sending new emails using this account

See Also:
Constant Field Values
Constructor Detail

EmailAccount

public EmailAccount(java.lang.String login,
                    java.lang.String pswd,
                    java.lang.String srvr,
                    int port,
                    boolean ssl,
                    boolean auth,
                    int emailsPerH,
                    boolean monoCon)
             throws java.lang.IllegalArgumentException
Constructs a new EmailAccount object

Parameters:
login - Email account login
pswd - Email account pswd
srvr - SMTP Server for the email account
port - Default port number for the SMTP Server
ssl - Use secured connection
auth - SMTP Server needs user authentication
emailsPerH - Number of emails to send every hour
monoCon - The email accound supports only one connection at a time
Throws:
java.lang.IllegalArgumentException

EmailAccount

public EmailAccount(java.lang.String login,
                    java.lang.String pswd,
                    java.lang.String srvr,
                    java.lang.String port,
                    java.lang.String ssl,
                    java.lang.String auth,
                    java.lang.String emailsPerH,
                    java.lang.String monoCon)
Constructs a new EmailAccount object

Parameters:
login - Email account login
pswd - Email account pswd
srvr - SMTP Server for the email account
port - Default port number for the SMTP Server
ssl - Use secured connection
auth - SMTP Server needs user authentication
emailsPerH - Number of emails to send every hour
monoCon - The email accound supports only one connection at a time
Throws:
java.lang.IllegalArgumentException

EmailAccount

public EmailAccount(java.lang.String csvLine)
             throws java.lang.IllegalArgumentException
Constructs a new EmailAccount object

Parameters:
csvLine - A CSV line containing all parameters needed to construct a valid EmailAccount object. Content must be composed like that : [login;password;smtp_server;port_number;use_ssl;needs_authentication;emails_per_hour;mono_connection]
Throws:
java.lang.IllegalArgumentException

EmailAccount

public EmailAccount(java.lang.String login,
                    java.lang.String pswd,
                    java.lang.String srvr,
                    int port,
                    boolean ssl,
                    EmailAccount.ServerProtocol protocol)
Constructs a new EmailAccount object. Used to specify the server protocole

Parameters:
login - Email account login
pswd - Email account pswd
srvr - SMTP Server for the email account
port - Default port number for the SMTP Server
ssl - Use secured connection
protocole - The protocole used to connect and communicate with th server
Method Detail

getServerProtocol

public EmailAccount.ServerProtocol getServerProtocol()
Gets the identifier of the protocol used to connect to the server

Returns:
The identifier of the protocol used to connect to the server

getHost

public java.lang.String getHost()
Gets the host of the server

Returns:
The host of the server

updateLastSendTimeMillis

public void updateLastSendTimeMillis()
Set last time (millis) when last email was sent.


getLastSendTimeMillis

public long getLastSendTimeMillis()
Get the last time (millis) when the last email was sent

Returns:
Last time (millis) when the last email was sent

getEmailsPerHour

public int getEmailsPerHour()
Get the number of emails to send per one hour

Returns:
The number of emails to send per one hour

getLogin

public java.lang.String getLogin()
Get the user login of the email account

Returns:
the user login of the email account

getPassword

public java.lang.String getPassword()
Get the password of the email account

Returns:
The password of the email account

getSmtpServer

public java.lang.String getSmtpServer()
Get the SMTP Server address for the email account

Returns:
The SMTP Server address for the email account

getPortNumber

public int getPortNumber()
Get the default port number of the SMTP Server for the email account

Returns:
The default port number of the SMTP Server for the email account

needSSL

public java.lang.Boolean needSSL()
Returns true if the connection with SMTP Server is secured

Returns:
true if the connection with SMTP Server is secured

needAuthentication

public java.lang.Boolean needAuthentication()
Gets true if the SMTP Server needs user authentication

Returns:
true if the SMTP Server needs user authentication

isReadyForSendingNewEmail

public boolean isReadyForSendingNewEmail()
Gets true if the email account is ready to send an other email via the SMTP Server

Returns:
true if the email account is ready to send an other email via the SMTP Server

setReadyForSendingNewEmail

public void setReadyForSendingNewEmail()
Sets the ready status of the email account. isReadyForSendingNewEmail() may return false if wait period is not elapsed or the account is disabled.


isBusy

public boolean isBusy()
Gets true if the email account is busy i.e sending an email

Returns:
true if the email account is busy i.e sending an email

setBusyStatus

public boolean setBusyStatus(boolean busy)
Sets on the busy status or off

Parameters:
busy - Set to true to make the email account busy
Returns:
The last email account busy status

isDisabled

public boolean isDisabled()
Gets true if the email account is disabled

Returns:
true if the email account is disabled

setDisabled

public void setDisabled()
Set the email account status to disabled