org.codemonkey.simplejavamail
Enum TransportStrategy

java.lang.Object
  extended by java.lang.Enum<TransportStrategy>
      extended by org.codemonkey.simplejavamail.TransportStrategy
All Implemented Interfaces:
Serializable, Comparable<TransportStrategy>

public enum TransportStrategy
extends Enum<TransportStrategy>

Defines the various types of transport protocols and implements respective properties so that a Session may be configured using a TransportStrategy implementation.

Author:
Benny Bottema

Enum Constant Summary
SMTP_PLAIN
          Simplest possible form: only vanilla ".smtp." property names and no extra properties.
SMTP_SSL
          SMTPS / SSL transport strategy, that returns the ".smtps." variation of the SMTP_PLAIN version.
SMTP_TLS
          NOTE: this code is in untested beta state Uses standard ".smtp." property names (like SMTP_PLAIN).
 
Method Summary
 Properties generateProperties()
          Base implementation that simply returns an empty list of properties.
static TransportStrategy valueOf(String name)
          Returns the enum constant of this type with the specified name.
static TransportStrategy[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

SMTP_PLAIN

public static final TransportStrategy SMTP_PLAIN
Simplest possible form: only vanilla ".smtp." property names and no extra properties. Additionally the transport protocol is explicitly set to smtp.


SMTP_SSL

public static final TransportStrategy SMTP_SSL
SMTPS / SSL transport strategy, that returns the ".smtps." variation of the SMTP_PLAIN version. Additionally the transport protocol is explicitly set to smtps. Finally, he property "mail.smtps.quitwait" is set to false, to get rid of a strange SSL exception:
 javax.mail.MessagingException: Exception reading response;
 nested exception is:
        javax.net.ssl.SSLException: Unsupported record version Unknown-50.49
 (..)
 
The mail is sent but the exception is unwanted. The property quitwait means If set to false, the QUIT command is sent and the connection is immediately closed. If set to true (the default), causes the transport to wait for the response to the QUIT command
- source


SMTP_TLS

public static final TransportStrategy SMTP_TLS
NOTE: this code is in untested beta state

Uses standard ".smtp." property names (like SMTP_PLAIN). Additionally the transport protocol is explicitly set to smtp. Finally, the property "mail.smtp.starttls.enable" is being set to true.

Method Detail

values

public static TransportStrategy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (TransportStrategy c : TransportStrategy.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static TransportStrategy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

generateProperties

public Properties generateProperties()
Base implementation that simply returns an empty list of properties. Should be overridden by the various strategies where appropriate.

Returns:
An empty Properties instance.


Copyright © 2011. All Rights Reserved.