public class MailSender extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MailSender.MailAction
MailAction defines the action for the mail.
|
Modifier and Type | Method and Description |
---|---|
void |
activateDebugStream()
Activate logging of this senders session to a Stream.
|
String |
getCommunicationType()
|
String |
getDebugStreamContents()
Get the contents of the debugging stream.
|
static MailSender |
getDefaultSender()
Returns a default MailSender which properties are taken from configuration:
SMTP host under Configuration/Communication
Mail sender under Configuration/Communication
SMTP Username under Configuration/Communication
SMTP Password under Configuration/Communication
Type of SMTP communication under Configuration/Communication
MailSender.MailAction defined under Configuration/Communication
MailQueue is allowed
|
String |
getHost()
return the smtp host
|
MailSender.MailAction |
getMailAction() |
static MailSender.MailAction |
getMailActionFromConfiguration()
Get mail action from configuration
|
MailQueueItem |
getMailQueueItem()
Returns a
MailQueueItem which could be set after sending mail |
Message |
getMessage()
HINT: Use
MessageTemplate interface! |
int |
getPort() |
String |
getSender()
return the sender address
|
Pair<String,String> |
getSenderCredentials()
Get the sender credentials
|
static MailSender |
getSenderForMailBox(MailBox mb)
Returns a MailSender which properties are taken from a mailbox.
|
Session |
getSession() |
Persistent |
getUserOrMailbox() |
boolean |
isMailQueueAllowed()
determine, if mail queue should be used
|
static boolean |
send(String[] to,
String[] cc,
String[] bcc,
String from,
String host,
String subject,
String msgText,
String contentType,
Object[] parts,
String[] fileNames)
Deprecated.
since ep9.0 - Use
MessageTemplate interface! |
static boolean |
send(String[] to,
String[] cc,
String[] bcc,
String from,
String host,
String subject,
String msgText,
String charset,
String contentType,
Object[] parts,
String[] fileNames)
Deprecated.
since ep9.0 - Use
MessageTemplate interface! |
static boolean |
send(String[] to,
String from,
String subject,
String msgText,
String contentType,
Object[] parts,
String[] fileNames)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
static boolean |
send(String[] to,
String from,
String host,
String subject,
String msgText,
String contentType)
Deprecated.
since ep9.0 - Use
MessageTemplate interface! |
static boolean |
send(String[] to,
String from,
String host,
String subject,
String msgText,
String[] files)
Deprecated.
since ep9.0 - Use
MessageTemplate interface! |
static boolean |
send(String to,
String from,
String host,
String subject,
String msgText)
Deprecated.
since ep9.0 - Use
MessageTemplate interface! |
static boolean |
send(String to,
String from,
String host,
String subject,
String msgText,
String contentType)
Deprecated.
since ep9.0 - Use
MessageTemplate interface! |
static void |
sendMailQueueItem(MailQueueItem mqitem)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMessage(Message msg,
MailSender.MailAction actionIn)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMessage(Message msg,
MailSender.MailAction actionIn,
boolean log,
Persistent contextObj)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMsg(String to,
String subject,
String message)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMsg(String to,
String subject,
String message,
String contentType)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMsg(String to,
String cc,
String bcc,
String subject,
String message,
String contentType)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMsg(String to,
String cc,
String bcc,
String subject,
String msgText,
String charset,
String contentType,
Object[] parts,
String[] fileNames)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMsg(String to,
String cc,
String bcc,
String subject,
String msgText,
String charset,
String contentType,
Object[] parts,
String[] fileNames,
String replyto_msgid,
boolean isHTML)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
boolean |
sendMsgHTML(String to,
String cc,
String bcc,
String subject,
String msgText,
String charset,
String contentType,
Object[] attachments,
String[] fileNames,
Object[] inlineparts,
String replyto_msgid)
Deprecated.
since ep10.0 - Use
MessageTemplate interface! |
static void |
sendToAdmin(String message)
Deprecated.
since ep10.0 - Use
Admin interface! |
static void |
sendToAdmin(String subject,
String message)
Deprecated.
since ep10.0 - Use
Admin interface! |
static void |
sendToAdmin(String subject,
String message,
MailSender.MailAction action)
Deprecated.
since ep10.0 - Use
Admin interface! |
void |
setCommunicationType(String type)
Sets the communication type.
|
void |
setDefaultProps()
set default mailsender properties defined in configuration
Mails can be only put into the mailqueue if they are send by default, mailbox or user properties.
|
void |
setDefaultProps(MailBox mb)
Set mailsender properties as defined for a mailbox
Mails can be only put into the mailqueue if they are send by default, mailbox or user properties.
|
void |
setDefaultProps(Properties props) |
void |
setMailAction(MailSender.MailAction action)
Sets another
MailSender.MailAction |
void |
setPropsFromMailBox(MailBox mb)
set mailsender properties from mailbox data.
|
void |
setPropsFromUser(User u)
set mailsender properties from mailbox data.
|
void |
setSender(String mailAddress)
Sets an alternative sender.
|
void |
setSenderAndCredentials(String mailAddress,
String uname,
String passwd)
Sets alternative sender credentials.
|
void |
setSMTPHost(String smtphost)
Sets alternative SMTP host (+ optionally SMTP port, separated by colon).
|
public static MailSender getDefaultSender()
MailSender.MailAction
defined under Configuration/Communicationpublic static MailSender getSenderForMailBox(MailBox mb)
getDefaultSender()
is returned.
MailSender.MailAction
defined under Configuration/Communicationmb
- the mailboxpublic boolean isMailQueueAllowed()
public String getCommunicationType()
public void setCommunicationType(String type)
MailSender.MailAction
is NO_QUEUE!public String getHost()
public String getSender()
public Message getMessage()
MessageTemplate
interface!public int getPort()
public void setSender(String mailAddress)
mailAddress
- public Pair<String,String> getSenderCredentials()
public void setSenderAndCredentials(String mailAddress, String uname, String passwd)
mailAddress
- the mail address of useruname
- the user namepasswd
- the password of given userpublic void setSMTPHost(String smtphost)
MailSender.MailAction
is NO_QUEUE!smtphost
- public void setMailAction(MailSender.MailAction action)
MailSender.MailAction
public MailSender.MailAction getMailAction()
MailSender.MailAction
public MailQueueItem getMailQueueItem()
MailQueueItem
which could be set after sending mailMailQueueItem
, otherwise null
public Persistent getUserOrMailbox()
@Deprecated public static boolean send(String to, String from, String host, String subject, String msgText)
MessageTemplate
interface!to
- the recipientfrom
- the senderhost
- the mailer hostsubject
- the subject textmsgText
- the message text@Deprecated public static boolean send(String to, String from, String host, String subject, String msgText, String contentType)
MessageTemplate
interface!@Deprecated public static boolean send(String[] to, String from, String host, String subject, String msgText, String contentType)
MessageTemplate
interface!@Deprecated public static boolean send(String[] to, String from, String host, String subject, String msgText, String[] files)
MessageTemplate
interface!@Deprecated public static boolean send(String[] to, String[] cc, String[] bcc, String from, String host, String subject, String msgText, String contentType, Object[] parts, String[] fileNames)
MessageTemplate
interface!@Deprecated public static boolean send(String[] to, String[] cc, String[] bcc, String from, String host, String subject, String msgText, String charset, String contentType, Object[] parts, String[] fileNames)
MessageTemplate
interface!@Deprecated public static boolean send(String[] to, String from, String subject, String msgText, String contentType, Object[] parts, String[] fileNames)
MessageTemplate
interface!to
- the recipientsfrom
- the sendersubject
- the subject textmsgText
- the message textcontentType
- the mime-type (if null, default is 'text/plain')parts
- the attached mime body parts or files (path names leading to the files,
thus, a String[]
).
If the parameter contains paths to files, you can use the next parameter
fileNames
to give names to the files.fileNames
- if parts
contains files, then you can provide filenames
in this array. Ensure that it has a name for every file listed in the parts
array.
The first element of the parts
array will be given the first name from the
fileNames
array. If you set fileNames
to null
,
the real file names of the files will be used.MailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.@Deprecated public boolean sendMsg(String to, String subject, String message)
MessageTemplate
interface!to
- the recipient(s)subject
- the subject textmessage
- the message textMailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.@Deprecated public boolean sendMsg(String to, String subject, String message, String contentType)
MessageTemplate
interface!to
- the recipient(s)subject
- the subject textmessage
- the message textcontentType
- the mime-type (if null, default is 'text/plain')MailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.@Deprecated public boolean sendMsg(String to, String cc, String bcc, String subject, String message, String contentType)
MessageTemplate
interface!to
- the recipient(s)cc
- the cc recipient(s)bcc
- the bcc recipient(s)subject
- the subject textmessage
- the message textcontentType
- the mime-type (if null, default is 'text/plain')MailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.@Deprecated public boolean sendMsg(String to, String cc, String bcc, String subject, String msgText, String charset, String contentType, Object[] parts, String[] fileNames)
MessageTemplate
interface!to
- the recipient(s)cc
- the cc recipient(s)bcc
- the bcc recipient(s)subject
- the subject textmsgText
- the message textcharset
- the charset for message (could be null, then default is taken)contentType
- the mime-type (if null, default is 'text/plain')parts
- the attached mime body parts or files (path names leading to the files,
thus, a String[]
).
If the parameter contains paths to files, you can use the next parameter
fileNames
to give names to the files.fileNames
- if parts
contains files, then you can provide filenames
in this array. Ensure that it has a name for every file listed in the parts
array.
The first element of the parts
array will be given the first name from the
fileNames
array. If you set fileNames
to null
,
the real file names of the files will be used.MailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.@Deprecated public boolean sendMsg(String to, String cc, String bcc, String subject, String msgText, String charset, String contentType, Object[] parts, String[] fileNames, String replyto_msgid, boolean isHTML)
MessageTemplate
interface!to
- the recipient(s)cc
- the cc recipient(s)bcc
- the bcc recipient(s)subject
- the subject textmsgText
- the message textcharset
- the charset for message (could be null, then default is taken)contentType
- the mime-type (if null, default is 'text/plain')parts
- the attached mime body parts or files (path names leading to the files,
thus, a String[]
).
If the parameter contains paths to files, you can use the next parameter
fileNames
to give names to the files.fileNames
- if parts
contains files, then you can provide filenames
in this array. Ensure that it has a name for every file listed in the parts
array.
The first element of the parts
array will be given the first name from the
fileNames
array. If you set fileNames
to null
,
the real file names of the files will be used.replyto_msgid
- the message-id of the replying mailisHTML
- if true
, mail is sent as HTML mailMailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.@Deprecated public boolean sendMsgHTML(String to, String cc, String bcc, String subject, String msgText, String charset, String contentType, Object[] attachments, String[] fileNames, Object[] inlineparts, String replyto_msgid)
MessageTemplate
interface!to
- the recipient(s)cc
- the cc recipient(s)bcc
- the bcc recipient(s)subject
- the subject textmsgText
- the message text (in html format)charset
- the charset for message (could be null, then default is taken)contentType
- the mime-type (if null, default is 'text/html')attachments
- the attached mime body parts or files (path names leading to the files,
thus, a String[]
).
If the parameter contains paths to files, you can use the next parameter
fileNames
to give names to the files.fileNames
- if parts
contains files, then you can provide filenames
in this array. Ensure that it has a name for every file listed in the parts
array.
The first element of the parts
array will be given the first name from the
fileNames
array. If you set fileNames
to null
,
the real file names of the files will be used.inlineparts
- the attached mime inline parts of the text/html message (msgText)replyto_msgid
- the message-id of the replying mailMailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.public Session getSession()
@Deprecated public static void sendMailQueueItem(MailQueueItem mqitem) throws Exception
MessageTemplate
interface!Exception
@Deprecated public boolean sendMessage(Message msg, MailSender.MailAction actionIn) throws Exception
MessageTemplate
interface!MailSender.MailAction
)msg
- the message to sendactionIn
- the MailSender.MailAction
(QUEUE, DEFERRED, NO_QUEUE)true
, if mail was sent immediately otherwise false
Exception
@Deprecated public boolean sendMessage(Message msg, MailSender.MailAction actionIn, boolean log, Persistent contextObj) throws Exception
MessageTemplate
interface!Exception
@Deprecated public static void sendToAdmin(String message)
Admin
interface!message
- the message@Deprecated public static void sendToAdmin(String subject, String message)
Admin
interface!subject
- the subjectmessage
- the message@Deprecated public static void sendToAdmin(String subject, String message, MailSender.MailAction action)
Admin
interface!subject
- the subjectmessage
- the messagemessage
- the MailAction, if null the configured system default is takenpublic void setPropsFromMailBox(MailBox mb)
mb
- - the mailbox which mailadress (and credentials) should be used as senderpublic void setPropsFromUser(User u)
u
- - the u which mailadress (and mail credentials) should be used as senderpublic void setDefaultProps()
public void setDefaultProps(MailBox mb)
public void setDefaultProps(Properties props)
public static MailSender.MailAction getMailActionFromConfiguration()
public void activateDebugStream()
getDebugStreamContents()
.public String getDebugStreamContents()
activateDebugStream()
.@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.