org.opengts.util
Class SendMail

java.lang.Object
  extended by org.opengts.util.SendMail

public class SendMail
extends java.lang.Object


Nested Class Summary
static class SendMail.Args
          A container for the arguments of an email
static class SendMail.Attachment
          A container for an email attachment
 
Field Summary
static int _THREAD_CURRENT
           
static int _THREAD_DEBUG
           
static int _THREAD_NEW
           
static int _THREAD_NONE
           
static int _THREAD_POOL
           
static java.lang.String EXAMPLE_DOT_COM
           
static byte[] MAGIC_GIF_87a
           
static byte[] MAGIC_GIF_89a
           
static byte[] MAGIC_JPEG
           
static byte[] MAGIC_PNG
           
static java.lang.String SendMailArgs_className
           
static java.lang.String THREAD_CURRENT
           
static java.lang.String THREAD_DEBUG
           
static java.lang.String THREAD_NEW
           
static java.lang.String THREAD_NONE
           
static java.lang.String THREAD_POOL
           
static java.lang.String X_AlarmRule
           
static java.lang.String X_AssetId
           
static java.lang.String X_EventTime
           
static java.lang.String X_GPSLocation
           
static java.lang.String X_OriginatingIP
           
static java.lang.String X_OwnerId
           
static java.lang.String X_PageType
           
static java.lang.String X_Requestor
           
static java.lang.String X_StatusCode
           
 
Constructor Summary
SendMail()
           
 
Method Summary
static java.lang.String DefaultContentType(byte[] data)
          Returns the MIME contents type for the specified file contents
static java.lang.String getEMailAddress(java.lang.String addr)
          Filters and returns the base email address from the specified String.
For example, if the String "Jones<jones@example.com>" is passed to this method, then the value "jones@example.com" will be returned.
static java.lang.String getUserFromEmailAddress()
          Returns the mandatory SMTP user "From" email address.
static java.lang.String getUserFromEmailAddress(java.lang.String dftEmail)
          Returns the mandatory SMTP user "From" email address.
static boolean IsSendMailEnabled()
          Returns true if "SendMail" is enabled
static void main(java.lang.String[] argv)
          Command-line debug/testing entry point
static boolean send(java.util.Properties headers, java.lang.String from, java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String subject, java.lang.String msgBody, SendMail.Attachment attach)
          Sends an email
static boolean send(java.lang.String from, java.lang.String to, java.lang.String subject, java.lang.String msgBody)
          Sends an email
static boolean send(java.lang.String from, java.lang.String to, java.lang.String subject, java.lang.String msgBody, SendMail.Attachment attach)
          Sends an email
static boolean send(java.lang.String from, java.lang.String to, java.lang.String cc, java.lang.String bcc, java.lang.String subject, java.lang.String msgBody, SendMail.Attachment attach)
          Sends an email
static void SetThreadModel(java.lang.String model)
          Sets the 'thread model' for email sent by this class.
The valid values are THREAD_CURRENT, THREAD_POOL, THREAD_NEW, or THREAD_DEBUG.
static void SetThreadModel(java.lang.String model, boolean show)
          Sets the 'thread model' for email sent by this class.
The valid values are THREAD_CURRENT, THREAD_POOL, THREAD_NEW, or THREAD_DEBUG.
static boolean validateAddress(java.lang.String addr)
          Validate the specified email address.
static boolean validateAddresses(java.lang.String addr)
          Validate the specified list of comma-separated email addresses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SendMailArgs_className

public static final java.lang.String SendMailArgs_className
See Also:
Constant Field Values

EXAMPLE_DOT_COM

public static final java.lang.String EXAMPLE_DOT_COM
See Also:
Constant Field Values

X_OwnerId

public static final java.lang.String X_OwnerId
See Also:
Constant Field Values

X_AssetId

public static final java.lang.String X_AssetId
See Also:
Constant Field Values

X_PageType

public static final java.lang.String X_PageType
See Also:
Constant Field Values

X_Requestor

public static final java.lang.String X_Requestor
See Also:
Constant Field Values

X_OriginatingIP

public static final java.lang.String X_OriginatingIP
See Also:
Constant Field Values

X_EventTime

public static final java.lang.String X_EventTime
See Also:
Constant Field Values

X_StatusCode

public static final java.lang.String X_StatusCode
See Also:
Constant Field Values

X_AlarmRule

public static final java.lang.String X_AlarmRule
See Also:
Constant Field Values

X_GPSLocation

public static final java.lang.String X_GPSLocation
See Also:
Constant Field Values

MAGIC_GIF_87a

public static final byte[] MAGIC_GIF_87a

MAGIC_GIF_89a

public static final byte[] MAGIC_GIF_89a

MAGIC_JPEG

public static final byte[] MAGIC_JPEG

MAGIC_PNG

public static final byte[] MAGIC_PNG

THREAD_NONE

public static final java.lang.String THREAD_NONE
See Also:
Constant Field Values

_THREAD_NONE

public static final int _THREAD_NONE
See Also:
Constant Field Values

THREAD_CURRENT

public static final java.lang.String THREAD_CURRENT
See Also:
Constant Field Values

_THREAD_CURRENT

public static final int _THREAD_CURRENT
See Also:
Constant Field Values

THREAD_POOL

public static final java.lang.String THREAD_POOL
See Also:
Constant Field Values

_THREAD_POOL

public static final int _THREAD_POOL
See Also:
Constant Field Values

THREAD_NEW

public static final java.lang.String THREAD_NEW
See Also:
Constant Field Values

_THREAD_NEW

public static final int _THREAD_NEW
See Also:
Constant Field Values

THREAD_DEBUG

public static final java.lang.String THREAD_DEBUG
See Also:
Constant Field Values

_THREAD_DEBUG

public static final int _THREAD_DEBUG
See Also:
Constant Field Values
Constructor Detail

SendMail

public SendMail()
Method Detail

IsSendMailEnabled

public static boolean IsSendMailEnabled()
Returns true if "SendMail" is enabled

Returns:
True if "SendMail" is enabled, otherwise false

SetThreadModel

public static void SetThreadModel(java.lang.String model)
Sets the 'thread model' for email sent by this class.
The valid values are THREAD_CURRENT, THREAD_POOL, THREAD_NEW, or THREAD_DEBUG.

Parameters:
model - The specified thread model.

SetThreadModel

public static void SetThreadModel(java.lang.String model,
                                  boolean show)
Sets the 'thread model' for email sent by this class.
The valid values are THREAD_CURRENT, THREAD_POOL, THREAD_NEW, or THREAD_DEBUG.

Parameters:
model - The specified thread model.
show - True to display the thread model when sending an email (debug purposes only).

getUserFromEmailAddress

public static java.lang.String getUserFromEmailAddress()
Returns the mandatory SMTP user "From" email address. (The use of this email address for the 'From' address is not enforced).

Returns:
The mandatory SMTP user "From" email address.

getUserFromEmailAddress

public static java.lang.String getUserFromEmailAddress(java.lang.String dftEmail)
Returns the mandatory SMTP user "From" email address. (The use of this email address for the 'From' address is not enforced).

Parameters:
dftEmail - The default email if the SMTP 'From' property has not been set.
Returns:
The mandatory SMTP user "From" email address.

send

public static boolean send(java.lang.String from,
                           java.lang.String to,
                           java.lang.String subject,
                           java.lang.String msgBody)
Sends an email

Parameters:
from - The sender of the email
to - A comma-separated list of email recipients.
subject - The email subject.
msgBody - The email message body.
Returns:
True

send

public static boolean send(java.lang.String from,
                           java.lang.String to,
                           java.lang.String subject,
                           java.lang.String msgBody,
                           SendMail.Attachment attach)
Sends an email

Parameters:
from - The sender of the email
to - A comma-separated list of email recipients.
subject - The email subject.
msgBody - The email message body.
attach - An email attachment
Returns:
True

send

public static boolean send(java.lang.String from,
                           java.lang.String to,
                           java.lang.String cc,
                           java.lang.String bcc,
                           java.lang.String subject,
                           java.lang.String msgBody,
                           SendMail.Attachment attach)
Sends an email

Parameters:
from - The sender of the email
to - A comma-separated list of 'To:' email recipients.
cc - A comma-separated list of 'Cc:' email recipients.
bcc - A comma-separated list of 'Bcc:' email recipients.
subject - The email subject.
msgBody - The email message body.
attach - An email attachment
Returns:
True

send

public static boolean send(java.util.Properties headers,
                           java.lang.String from,
                           java.lang.String[] to,
                           java.lang.String[] cc,
                           java.lang.String[] bcc,
                           java.lang.String subject,
                           java.lang.String msgBody,
                           SendMail.Attachment attach)
Sends an email

Parameters:
from - The sender of the email
to - An array of 'To:' email recipients.
cc - An array of 'Cc:' email recipients.
bcc - An array of 'Bcc:' email recipients.
subject - The email subject.
msgBody - The email message body.
attach - An email attachment
Returns:
True

DefaultContentType

public static java.lang.String DefaultContentType(byte[] data)
Returns the MIME contents type for the specified file contents

Parameters:
data - The file contents
Returns:
The MIME content type

validateAddresses

public static boolean validateAddresses(java.lang.String addr)
Validate the specified list of comma-separated email addresses.

Parameters:
addr - A comma-separated list of email addresses
Returns:
True if all addresses in the list are valid, false otherwise

validateAddress

public static boolean validateAddress(java.lang.String addr)
Validate the specified email address.

Parameters:
addr - The email address to validate.
Returns:
True if the specified email address is valid, false otherwise

getEMailAddress

public static java.lang.String getEMailAddress(java.lang.String addr)
Filters and returns the base email address from the specified String.
For example, if the String "Jones<jones@example.com>" is passed to this method, then the value "jones@example.com" will be returned.

Parameters:
addr - The email address to filter.
Returns:
The filtered email address, or null if the specified email address is invalid.

main

public static void main(java.lang.String[] argv)
Command-line debug/testing entry point

Parameters:
argv - The command-line arguments