com.ezprotocols.ezsmtp
Class EzSMTP

java.lang.Object
  |
  +--com.ezprotocols.ezsmtp.EzSMTP
All Implemented Interfaces:
java.io.Serializable

public class EzSMTP
extends java.lang.Object
implements java.io.Serializable

EzSMTP component provides a simple interface for sending electronic mail messages. EzSMTP javabean supports simple and HTML messages, priority, user authentification, multiple file attachments and more!


  import com.ezprotocols.ezsmtp.*;
  // This example simply sends a text email
  public class SendMail {
   public static void main(String[] args) {
     try{
       EzSMTP smtp = new EzSMTP();
       smtp.setTo("info@ezprotocols.com");
       smtp.setFrom("info@ezprotocols.com");
       smtp.setSubject("EzSMTP Simple Test");
       smtp.setMailServer("relais.videotron.ca");
       smtp.setBody("EzSMTP Simple Test Body.");
       smtp.sendMail();
     }catch(EzSMTPException ex){
       System.out.println(ex.getMessage());
     }
   }
  }

See Also:
Serialized Form

Field Summary
static int PRIORITY_HIGH
           
static int PRIORITY_HIGHEST
           
static int PRIORITY_LOW
           
static int PRIORITY_LOWEST
           
static int PRIORITY_NORMAL
           
 
Constructor Summary
EzSMTP()
           
 
Method Summary
 void addEzSMTPEventListener(EzSMTPEventListener client)
          Registers to receive events (serverReply).
 void disconnect()
          Disconnects from the SMTP Server.
 java.lang.String getAbout()
          Gets information about EzSMTP.
 java.lang.String getAttachedFile()
          Gets the name of the file(s) to attach with the mail.
 java.lang.String getBcc()
          Gets the Bcc address.
 java.lang.String getBody()
          Gets the body of the electronic mail.
 java.lang.String getCc()
          Gets the Cc address.
 boolean getConnected()
          Indicates if currently connected to the SMTP Server.
 java.lang.String getFrom()
          Gets the mail address of the sender.
 java.lang.String getHelo()
          Gets identity used when executing the SMTP HELO command.
 int getMailPort()
          Gets the SMTP Server port number.
 java.lang.String getMailServer()
          Gets the SMTP server address.
 java.lang.String getPassword()
          Gets the user password used for authentication.
 int getPriority()
          Gets the priority of the electronic mail.
 java.lang.String getSerialKey()
          Gets the Serial Key used to activate the full version.
 java.lang.String getSubject()
          Gets the mail subject.
 int getTimeout()
          Gets the Timeout to open the connection with the SMTP Server.
 java.lang.String getTo()
          Gets the recipient address(es).
 java.lang.String getUsername()
          Gets the username used for authentication.
 java.lang.String getVersion()
          Gets the version number of EzSMTP.
 boolean isAuthLogin()
          Indicates if the SMTP Server needs authentication.
 boolean isHtmlContent()
          True if the body of the mail contains HTML.
 boolean isMultipleSend()
          Gets MultipleSend flag which determines whether to disconnect after the sendMail() method is called.
 void removeEzSMTPEventListener(EzSMTPEventListener client)
          UnRegisters from receiving events.
 void sendMail()
          Sends an electronic mail.
 void setAbout(java.lang.String s)
           
 void setAttachedFile(java.lang.String f)
          Sets the name of the file to attach with the mail.
 void setAuthLogin(boolean a)
          Set to True if SMTP Server needs authentication.
 void setBcc(java.sql.ResultSet rs, int fieldId)
          Sets the Bcc address from a ResultSet.
 void setBcc(java.lang.String s)
          Sets the Bcc address.
 void setBody(java.lang.String s)
          Sets the body of the electronic mail.
 void setCc(java.sql.ResultSet rs, int fieldId)
          Sets the CC address from a ResultSet.
 void setCc(java.lang.String s)
          Sets the CC address.
 void setFrom(java.lang.String s)
          Sets the mail address of the sender.
 void setHelo(java.lang.String s)
          Sets identity used when executing the SMTP HELO command.
 void setHtmlContent(boolean b)
          Set to True if the mail body contains HTML.
 void setMailPort(int port)
          Sets the SMTP Server port (Default is 25).
 void setMailServer(java.lang.String s)
          Sets the address of the SMTP Server.
 void setMultipleSend(boolean b)
          Sets MultipleSend flag which determines whether to disconnect after the sendMail() method called.
 void setPassword(java.lang.String p)
          Sets the user password for authentication with the SMTP Server.
 void setPriority(int p)
          Sets the priority of the electronic mail.
 void setSerialKey(java.lang.String k)
          Sets the Serial Key to activate the full version.
 void setSubject(java.lang.String s)
          Sets the mail subject.
 void setTimeout(int t)
          Sets the Timeout to open the connection with the SMTP Server.
 void setTo(java.sql.ResultSet rs, int fieldId)
          Sets the recipient(s) address from a ResultSet.
 void setTo(java.lang.String rcptTo)
          Sets the recipient(s) address.
 void setUsername(java.lang.String u)
          Sets the username for authentication with the SMTP Server.
 void setVersion(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIORITY_LOWEST

public static final int PRIORITY_LOWEST

PRIORITY_LOW

public static final int PRIORITY_LOW

PRIORITY_NORMAL

public static final int PRIORITY_NORMAL

PRIORITY_HIGH

public static final int PRIORITY_HIGH

PRIORITY_HIGHEST

public static final int PRIORITY_HIGHEST
Constructor Detail

EzSMTP

public EzSMTP()
Method Detail

disconnect

public void disconnect()
                throws EzSMTPException
Disconnects from the SMTP Server.

sendMail

public void sendMail()
              throws EzSMTPException
Sends an electronic mail.

addEzSMTPEventListener

public void addEzSMTPEventListener(EzSMTPEventListener client)
Registers to receive events (serverReply).

removeEzSMTPEventListener

public void removeEzSMTPEventListener(EzSMTPEventListener client)
UnRegisters from receiving events.

setTo

public void setTo(java.lang.String rcptTo)
Sets the recipient(s) address. For multiple recipients, separate them with a semicolon ';'.

setTo

public void setTo(java.sql.ResultSet rs,
                  int fieldId)
           throws EzSMTPException
Sets the recipient(s) address from a ResultSet.
Parameters:
ResultSet - rs: ResultSet containing Recipient Address(es).
int - fieldId: Id of the field from which to extract address.

setAttachedFile

public void setAttachedFile(java.lang.String f)
Sets the name of the file to attach with the mail. For multiple files, separate them with a semicolon ';'.

setAuthLogin

public void setAuthLogin(boolean a)
Set to True if SMTP Server needs authentication.

setPriority

public void setPriority(int p)
Sets the priority of the electronic mail.

setMultipleSend

public void setMultipleSend(boolean b)
Sets MultipleSend flag which determines whether to disconnect after the sendMail() method called. Setting MultipleSend to True allows multiple emails to be sent during a single SMTP session by invoking the sendMail() method and requires the disconnect() method to be called manually to end the connection.

setCc

public void setCc(java.lang.String s)
Sets the CC address. For multiple address, separate them with semicolon.

setUsername

public void setUsername(java.lang.String u)
Sets the username for authentication with the SMTP Server.

setHtmlContent

public void setHtmlContent(boolean b)
Set to True if the mail body contains HTML.

setPassword

public void setPassword(java.lang.String p)
Sets the user password for authentication with the SMTP Server.

setCc

public void setCc(java.sql.ResultSet rs,
                  int fieldId)
           throws EzSMTPException
Sets the CC address from a ResultSet.
Parameters:
ResultSet - rs: ResultSet containing Recipient Address(es).
int - fieldId: Id of the field from which to extract address.

setBcc

public void setBcc(java.lang.String s)
Sets the Bcc address. For multiple address, separate them with semicolons.

setBcc

public void setBcc(java.sql.ResultSet rs,
                   int fieldId)
            throws EzSMTPException
Sets the Bcc address from a ResultSet.
Parameters:
ResultSet - rs: ResultSet containing Recipient Address(es).

setSubject

public void setSubject(java.lang.String s)
Sets the mail subject.

setHelo

public void setHelo(java.lang.String s)
Sets identity used when executing the SMTP HELO command.

setTimeout

public void setTimeout(int t)
Sets the Timeout to open the connection with the SMTP Server. Default is 0 and implies that the option is disabled (Timeout = infinity).

setBody

public void setBody(java.lang.String s)
Sets the body of the electronic mail.

setMailPort

public void setMailPort(int port)
Sets the SMTP Server port (Default is 25).

setFrom

public void setFrom(java.lang.String s)
Sets the mail address of the sender.

setMailServer

public void setMailServer(java.lang.String s)
Sets the address of the SMTP Server.

setVersion

public void setVersion(java.lang.String s)

setAbout

public void setAbout(java.lang.String s)

setSerialKey

public void setSerialKey(java.lang.String k)
Sets the Serial Key to activate the full version.

getTo

public java.lang.String getTo()
Gets the recipient address(es).

getPriority

public int getPriority()
Gets the priority of the electronic mail.

getAttachedFile

public java.lang.String getAttachedFile()
Gets the name of the file(s) to attach with the mail.

getCc

public java.lang.String getCc()
Gets the Cc address.

isAuthLogin

public boolean isAuthLogin()
Indicates if the SMTP Server needs authentication.

isMultipleSend

public boolean isMultipleSend()
Gets MultipleSend flag which determines whether to disconnect after the sendMail() method is called.

getUsername

public java.lang.String getUsername()
Gets the username used for authentication.

getPassword

public java.lang.String getPassword()
Gets the user password used for authentication.

getBcc

public java.lang.String getBcc()
Gets the Bcc address.

getConnected

public boolean getConnected()
Indicates if currently connected to the SMTP Server.

getBody

public java.lang.String getBody()
Gets the body of the electronic mail.

getHelo

public java.lang.String getHelo()
Gets identity used when executing the SMTP HELO command.

getMailPort

public int getMailPort()
Gets the SMTP Server port number.

getSubject

public java.lang.String getSubject()
Gets the mail subject.

getTimeout

public int getTimeout()
Gets the Timeout to open the connection with the SMTP Server. Default is 0 and implies that the option is disabled (Timeout = infinity).

getMailServer

public java.lang.String getMailServer()
Gets the SMTP server address.

getFrom

public java.lang.String getFrom()
Gets the mail address of the sender.

isHtmlContent

public boolean isHtmlContent()
True if the body of the mail contains HTML.

getVersion

public java.lang.String getVersion()
Gets the version number of EzSMTP.

getAbout

public java.lang.String getAbout()
Gets information about EzSMTP.

getSerialKey

public java.lang.String getSerialKey()
Gets the Serial Key used to activate the full version.


Copyright © EzProtocols.com All Rights Reserved.