public class MailUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ENCRYPTED |
static java.lang.String |
PLAIN |
static java.lang.String |
STARTTLS |
static java.lang.String |
TRUSTED |
Constructor and Description |
---|
MailUtil() |
Modifier and Type | Method and Description |
---|---|
static javax.mail.Message |
convertBytesToMessage(byte[] msgContent)
Converts the given Byte Array to a javax.mail.Message
|
static javax.mail.Message |
convertBytesToMessage(byte[] msgContent,
javax.mail.Session s)
Converts the given Byte Array to a javax.mail.Message
|
static byte[] |
convertMessageToBytes(javax.mail.Message msg)
Converts the given message to Byte Array
|
static java.lang.String[] |
convertToArray(java.lang.String to)
Converts the given TO addresses (separated by comma) to an array
|
static javax.mail.internet.MimeMessage |
convertToMimeMessage(org.apache.poi.hsmf.MAPIMessage msg)
Method to convert MAPIMessage into MimeMessage.
|
static javax.mail.internet.InternetAddress |
extractSender(javax.mail.Message msg)
Extracts the sender address of a given message
|
static java.lang.String |
extractSubjectId(java.lang.String text)
The method tries to extract the pattern id of the given text.
|
static java.lang.String |
getMailSocketFactoryName(java.lang.String communicationType) |
static java.lang.String |
getMailSubjectPattern()
This method returns the subject prefix defined in property file.
|
static java.lang.String |
getMessageId(javax.mail.Message msg)
This method returns the message-id of the given message
|
static java.lang.String |
getSender()
Get the standard sender defined in configuration
|
static java.lang.String |
getSMTPCommunicationType()
|
static Pair<java.lang.String,java.lang.String> |
getSMTPCredentials()
get SMTP Credentials from configuration
|
static java.lang.String |
getSMTPHost()
Get the standard SMTP-host defined in configuration
|
static boolean |
isValidEmailAddress(java.lang.String email)
Method to validate given email address.
|
static java.lang.String |
sanitizeCRLF(java.lang.String s)
Replace sequences of CRLF characters by single spaces.
|
public static final java.lang.String PLAIN
public static final java.lang.String ENCRYPTED
public static final java.lang.String TRUSTED
public static final java.lang.String STARTTLS
public static byte[] convertMessageToBytes(javax.mail.Message msg)
msg
- the javax.mail.Messagenull
, if an error occurredpublic static java.lang.String sanitizeCRLF(java.lang.String s)
Message.setSubject(String)
c.f. [CSNC-2014-001]the
- String to sanitizepublic static javax.mail.Message convertBytesToMessage(byte[] msgContent)
msgContent
- the content as byte[]null
, if an error occurredpublic static javax.mail.Message convertBytesToMessage(byte[] msgContent, javax.mail.Session s)
msgContent
- the content as byte[]s
- the smtp session which shall be used to transport the messagenull
, if an error occurredpublic static java.lang.String getSMTPHost()
null
public static Pair<java.lang.String,java.lang.String> getSMTPCredentials()
public static java.lang.String getSMTPCommunicationType()
public static java.lang.String getSender()
public static java.lang.String[] convertToArray(java.lang.String to)
to
- the TO addressespublic static java.lang.String getMailSocketFactoryName(java.lang.String communicationType)
communicationType
- string represantation of the communication type: either:trusted or encrypted or any other string to unse plain communicationpublic static javax.mail.internet.MimeMessage convertToMimeMessage(org.apache.poi.hsmf.MAPIMessage msg) throws java.lang.Exception
Method to convert MAPIMessage into MimeMessage.
msg
- the MAPIMessage objectjava.lang.Exception
public static boolean isValidEmailAddress(java.lang.String email)
email
- the email address to validateTRUE
, if email is correct email addresspublic static java.lang.String getMailSubjectPattern()
null
if no parameter value is availablepublic static java.lang.String getMessageId(javax.mail.Message msg)
msg
- the MimeMessage objectnull
, if could not be determinedpublic static javax.mail.internet.InternetAddress extractSender(javax.mail.Message msg) throws java.lang.Exception
Extracts the sender address of a given message
msg
- the given messagejava.lang.Exception
public static java.lang.String extractSubjectId(java.lang.String text) throws java.lang.Exception
The method tries to extract the pattern id of the given text. If such an id is found, it is returned, otherwise null is returned.
text
- the given textjava.lang.Exception
@enterprise 9.0.33982 Copyright © 2001-2023 Groiss Informatics GmbH. All Rights Reserved.