Package org.appng.mail.impl
Class DefaultTransport
- java.lang.Object
-
- org.appng.mail.impl.DefaultTransport
-
- All Implemented Interfaces:
MailTransport
public class DefaultTransport extends Object implements MailTransport
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ALTERNATIVE
protected static String
CONTENT_TRANSFER_ENCODING
protected boolean
debug
protected boolean
disableSend
static String
HOST
protected static String
MIXED
protected Properties
p
static String
PORT
protected javax.mail.Session
session
protected static String
TEXT_HTML
protected static String
UTF_8
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultTransport()
DefaultTransport(String host, int port)
DefaultTransport(Properties props)
DefaultTransport(Properties props, String user, String password)
DefaultTransport(javax.mail.Session session)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.mail.Message
buildMessage(javax.mail.Message mimeMessage, Mail mail)
protected javax.mail.Message
buildMessage(Mail mail)
Mail
createMail()
Creates and returns a newMail
.void
disableSend()
String
getMailAsString(Mail mail)
boolean
isDebug()
boolean
isDisableSend()
Checks whether thisMailTransport
is disabled.void
send(Mail mail)
Send the givenMail
.protected void
send(Mail mail, Collection<String> invalidAdresses)
void
setDebug(boolean debug)
void
setDisableSend(boolean disableSend)
Enable/disable sending for thisMailTransport
.javax.mail.Address
toAddress(Address address)
-
-
-
Field Detail
-
TEXT_HTML
protected static final String TEXT_HTML
- See Also:
- Constant Field Values
-
CONTENT_TRANSFER_ENCODING
protected static final String CONTENT_TRANSFER_ENCODING
- See Also:
- Constant Field Values
-
UTF_8
protected static final String UTF_8
- See Also:
- Constant Field Values
-
MIXED
protected static final String MIXED
- See Also:
- Constant Field Values
-
ALTERNATIVE
protected static final String ALTERNATIVE
- See Also:
- Constant Field Values
-
HOST
public static final String HOST
- See Also:
- Constant Field Values
-
PORT
public static final String PORT
- See Also:
- Constant Field Values
-
session
protected javax.mail.Session session
-
p
protected Properties p
-
disableSend
protected boolean disableSend
-
debug
protected boolean debug
-
-
Constructor Detail
-
DefaultTransport
protected DefaultTransport()
-
DefaultTransport
public DefaultTransport(javax.mail.Session session)
-
DefaultTransport
public DefaultTransport(String host, int port)
-
DefaultTransport
public DefaultTransport(Properties props)
-
DefaultTransport
public DefaultTransport(Properties props, String user, String password)
-
-
Method Detail
-
createMail
public Mail createMail()
Description copied from interface:MailTransport
Creates and returns a newMail
.- Specified by:
createMail
in interfaceMailTransport
- Returns:
- the new
Mail
-
send
public void send(Mail mail) throws MailException
Description copied from interface:MailTransport
Send the givenMail
.- Specified by:
send
in interfaceMailTransport
- Parameters:
mail
- theMail
to send- Throws:
MailException
- if an error occurs while sending theMail
-
getMailAsString
public String getMailAsString(Mail mail)
Description copied from interface:MailTransport
Returns a string-representation if the givenMail
.
Attention: TheMail
may contain sensitive informations like passwords!- Specified by:
getMailAsString
in interfaceMailTransport
- Parameters:
mail
- theMail
to get the string-representation for- Returns:
- a
String
representation theMail
-
send
protected void send(Mail mail, Collection<String> invalidAdresses) throws MailException
- Throws:
MailException
-
buildMessage
protected javax.mail.Message buildMessage(Mail mail) throws MailException
- Throws:
MailException
-
buildMessage
protected javax.mail.Message buildMessage(javax.mail.Message mimeMessage, Mail mail) throws MailException
- Throws:
MailException
-
disableSend
public void disableSend()
-
isDisableSend
public boolean isDisableSend()
Description copied from interface:MailTransport
Checks whether thisMailTransport
is disabled.- Specified by:
isDisableSend
in interfaceMailTransport
- Returns:
true
if thisMailTransport
is disabled,false
otherwise.
-
setDisableSend
public void setDisableSend(boolean disableSend)
Description copied from interface:MailTransport
Enable/disable sending for thisMailTransport
. If set totrue
,Mail
s will be logged instead of being send.- Specified by:
setDisableSend
in interfaceMailTransport
-
isDebug
public boolean isDebug()
-
setDebug
public void setDebug(boolean debug)
-
toAddress
public javax.mail.Address toAddress(Address address) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
-