public class MailSender
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MailSender.MailAction
MailAction defines the action for the mail.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCommunicationType() |
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
|
java.lang.String |
getHost()
return the smtp host
|
MailSender.MailAction |
getMailAction() |
static MailSender.MailAction |
getMailActionFromConfiguration()
Get mail action from configuration
|
com.groiss.mail.MailQueueItem |
getMailQueueItem()
Returns a
MailQueueItem which could be set after sending mail |
javax.mail.Message |
getMessage()
HINT: Use
MessageTemplate interface! |
int |
getPort() |
java.lang.String |
getSender()
return the sender address
|
Pair<java.lang.String,java.lang.String> |
getSenderCredentials()
Get the sender credentials
|
javax.mail.Session |
getSession() |
Persistent |
getUserOrMailbox() |
boolean |
isMailQueueAllowed()
determine, if mail queue should be used
|
static boolean |
send(java.lang.String[] to,
java.lang.String[] cc,
java.lang.String[] bcc,
java.lang.String from,
java.lang.String host,
java.lang.String subject,
java.lang.String msgText,
java.lang.String contentType,
java.lang.Object[] parts,
java.lang.String[] fileNames)
Deprecated.
|
static boolean |
send(java.lang.String[] to,
java.lang.String[] cc,
java.lang.String[] bcc,
java.lang.String from,
java.lang.String host,
java.lang.String subject,
java.lang.String msgText,
java.lang.String charset,
java.lang.String contentType,
java.lang.Object[] parts,
java.lang.String[] fileNames)
Deprecated.
|
static boolean |
send(java.lang.String[] to,
java.lang.String from,
java.lang.String subject,
java.lang.String msgText,
java.lang.String contentType,
java.lang.Object[] parts,
java.lang.String[] fileNames)
Deprecated.
since ep 9.0 .. use none static methods
|
static boolean |
send(java.lang.String[] to,
java.lang.String from,
java.lang.String host,
java.lang.String subject,
java.lang.String msgText,
java.lang.String contentType)
Deprecated.
|
static boolean |
send(java.lang.String[] to,
java.lang.String from,
java.lang.String host,
java.lang.String subject,
java.lang.String msgText,
java.lang.String[] files)
Deprecated.
|
static boolean |
send(java.lang.String to,
java.lang.String from,
java.lang.String host,
java.lang.String subject,
java.lang.String msgText)
Deprecated.
since ep90 - use non-static methods instead
|
static boolean |
send(java.lang.String to,
java.lang.String from,
java.lang.String host,
java.lang.String subject,
java.lang.String msgText,
java.lang.String contentType)
Deprecated.
|
static void |
sendMailQueueItem(com.groiss.mail.MailQueueItem item)
Deprecated.
|
boolean |
sendMessage(javax.mail.Message msg,
MailSender.MailAction actionIn)
HINT: Use
MessageTemplate interface! |
boolean |
sendMessage(javax.mail.Message msg,
MailSender.MailAction actionIn,
boolean log,
Persistent contextObj)
HINT: Use
MessageTemplate interface! |
boolean |
sendMsg(java.lang.String to,
java.lang.String subject,
java.lang.String message)
HINT: Use
MessageTemplate interface! |
boolean |
sendMsg(java.lang.String to,
java.lang.String subject,
java.lang.String message,
java.lang.String contentType)
HINT: Use
MessageTemplate interface! |
boolean |
sendMsg(java.lang.String to,
java.lang.String cc,
java.lang.String bcc,
java.lang.String subject,
java.lang.String message,
java.lang.String contentType)
HINT: Use
MessageTemplate interface! |
boolean |
sendMsg(java.lang.String to,
java.lang.String cc,
java.lang.String bcc,
java.lang.String subject,
java.lang.String msgText,
java.lang.String charset,
java.lang.String contentType,
java.lang.Object[] parts,
java.lang.String[] fileNames)
HINT: Use
MessageTemplate interface! |
boolean |
sendMsg(java.lang.String to,
java.lang.String cc,
java.lang.String bcc,
java.lang.String subject,
java.lang.String msgText,
java.lang.String charset,
java.lang.String contentType,
java.lang.Object[] parts,
java.lang.String[] fileNames,
java.lang.String replyto_msgid,
boolean isHTML)
HINT: Use
MessageTemplate interface! |
boolean |
sendMsgHTML(java.lang.String to,
java.lang.String cc,
java.lang.String bcc,
java.lang.String subject,
java.lang.String msgText,
java.lang.String charset,
java.lang.String contentType,
java.lang.Object[] attachments,
java.lang.String[] fileNames,
java.lang.Object[] inlineparts,
java.lang.String replyto_msgid)
HINT: Use
MessageTemplate interface! |
static void |
sendToAdmin(java.lang.String message)
HINT: Use
Admin interface! |
static void |
sendToAdmin(java.lang.String subject,
java.lang.String message)
HINT: Use
Admin interface! |
static void |
sendToAdmin(java.lang.String subject,
java.lang.String message,
MailSender.MailAction action)
HINT: Use
Admin interface! |
void |
setCommunicationType(java.lang.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(java.util.Properties props) |
void |
setMailAction(MailSender.MailAction action)
Sets another
MailSender.MailAction |
void |
setPropsFromMailBox(com.groiss.mail.MailBox mb)
set mailsender properties from mailbox data.
|
void |
setPropsFromUser(User u)
set mailsender properties from mailbox data.
|
void |
setSender(java.lang.String mailAddress)
Sets an alternative sender.
|
void |
setSenderAndCredentials(java.lang.String mailAddress,
java.lang.String uname,
java.lang.String passwd)
Sets alternative sender credentials.
|
void |
setSMTPHost(java.lang.String smtphost)
Sets alternative SMTP host (+ optionally SMTP port, separated by colon).
|
public static MailSender getDefaultSender()
MailSender.MailAction
defined under Configuration/Communicationpublic boolean isMailQueueAllowed()
public java.lang.String getCommunicationType()
MailUtil.#getSMTPCommunicationType()
public void setCommunicationType(java.lang.String type)
MailSender.MailAction
is NO_QUEUE!public java.lang.String getHost()
public java.lang.String getSender()
public javax.mail.Message getMessage()
public int getPort()
public void setSender(java.lang.String mailAddress)
mailAddress
- public Pair<java.lang.String,java.lang.String> getSenderCredentials()
public void setSenderAndCredentials(java.lang.String mailAddress, java.lang.String uname, java.lang.String passwd)
mailAddress
- the mail address of useruname
- the user namepasswd
- the password of given userpublic void setSMTPHost(java.lang.String smtphost)
MailSender.MailAction
is NO_QUEUE!smtphost
- public void setMailAction(MailSender.MailAction action)
MailSender.MailAction
public MailSender.MailAction getMailAction()
MailSender.MailAction
public com.groiss.mail.MailQueueItem getMailQueueItem()
MailQueueItem
which could be set after sending mailMailQueueItem
, otherwise null
public Persistent getUserOrMailbox()
User
or MailBox
object
which has been defined as sender with methods sendPropsFromUser() or sendPropsFormMailBox();
otherwise null
is returned@Deprecated public static boolean send(java.lang.String to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText)
to
- the recipientfrom
- the senderhost
- the mailer hostsubject
- the subject textmsgText
- the message text@Deprecated public static boolean send(java.lang.String to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String contentType)
@Deprecated public static boolean send(java.lang.String[] to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String contentType)
@Deprecated public static boolean send(java.lang.String[] to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String[] files)
@Deprecated public static boolean send(java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String contentType, java.lang.Object[] parts, java.lang.String[] fileNames)
@Deprecated public static boolean send(java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String charset, java.lang.String contentType, java.lang.Object[] parts, java.lang.String[] fileNames)
@Deprecated public static boolean send(java.lang.String[] to, java.lang.String from, java.lang.String subject, java.lang.String msgText, java.lang.String contentType, java.lang.Object[] parts, java.lang.String[] fileNames)
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.action
- the MailSender.MailAction
MailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.public boolean sendMsg(java.lang.String to, java.lang.String subject, java.lang.String message)
to
- the recipient(s)subject
- the subject textmsgText
- the message textMailSender.MailAction
is NO_QUEUE) or
if mail has been inserted into mail queue. In all other cases a ApplicationException is thrown.public boolean sendMsg(java.lang.String to, java.lang.String subject, java.lang.String message, java.lang.String contentType)
to
- the recipient(s)subject
- the subject textmsgText
- 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.public boolean sendMsg(java.lang.String to, java.lang.String cc, java.lang.String bcc, java.lang.String subject, java.lang.String message, java.lang.String contentType)
to
- the recipient(s)cc
- the cc recipient(s)bcc
- the bcc recipient(s)subject
- the subject textmsgText
- 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.public boolean sendMsg(java.lang.String to, java.lang.String cc, java.lang.String bcc, java.lang.String subject, java.lang.String msgText, java.lang.String charset, java.lang.String contentType, java.lang.Object[] parts, java.lang.String[] fileNames)
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.public boolean sendMsg(java.lang.String to, java.lang.String cc, java.lang.String bcc, java.lang.String subject, java.lang.String msgText, java.lang.String charset, java.lang.String contentType, java.lang.Object[] parts, java.lang.String[] fileNames, java.lang.String replyto_msgid, boolean isHTML)
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.public boolean sendMsgHTML(java.lang.String to, java.lang.String cc, java.lang.String bcc, java.lang.String subject, java.lang.String msgText, java.lang.String charset, java.lang.String contentType, java.lang.Object[] attachments, java.lang.String[] fileNames, java.lang.Object[] inlineparts, java.lang.String replyto_msgid)
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 javax.mail.Session getSession()
@Deprecated public static void sendMailQueueItem(com.groiss.mail.MailQueueItem item) throws java.lang.Exception
java.lang.Exception
public boolean sendMessage(javax.mail.Message msg, MailSender.MailAction actionIn) throws java.lang.Exception
MessageTemplate
interface!MailSender.MailAction
)msg
- the message to sendaction
- the MailSender.MailAction
(QUEUE, DEFERRED, NO_QUEUE)true
, if mail was sent immediately otherwise false
java.lang.Exception
public boolean sendMessage(javax.mail.Message msg, MailSender.MailAction actionIn, boolean log, Persistent contextObj) throws java.lang.Exception
java.lang.Exception
public static void sendToAdmin(java.lang.String message)
Admin
interface!message
- the messagepublic static void sendToAdmin(java.lang.String subject, java.lang.String message)
Admin
interface!subject
- the subjectmessage
- the messagepublic static void sendToAdmin(java.lang.String subject, java.lang.String message, MailSender.MailAction action)
Admin
interface!subject
- the subjectmessage
- the messagemessage
- the MailAction, if null the configured system default is takenpublic void setPropsFromMailBox(com.groiss.mail.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(java.util.Properties props)
public static MailSender.MailAction getMailActionFromConfiguration()
@enterprise 9.0.33982 Copyright © 2001-2023 Groiss Informatics GmbH. All Rights Reserved.