Package com.atlassian.confluence.it.mail
Class MailUtils
- java.lang.Object
-
- com.atlassian.confluence.it.mail.MailUtils
-
public class MailUtils extends Object
Static methods for interacting with email messages.
-
-
Constructor Summary
Constructors Constructor Description MailUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static javax.mail.internet.MimeMessage
extractFirstEmailAddressedTo(User user, List<javax.mail.internet.MimeMessage> allMessages)
static Collection<javax.mail.internet.MimeMessage>
filterBySubject(Collection<javax.mail.internet.MimeMessage> messages, String subject)
static String
getBody(javax.mail.internet.MimeMessage smtpMessage)
Deprecated.since 7.6.0, useMailUtils.getBody(Message)
static Document
getDocument(javax.mail.internet.MimeMessage message)
static Iterable<javax.mail.internet.MimeMessage>
getEmailAddressedToUser(User user, List<javax.mail.internet.MimeMessage> allMessages)
static String
getFirstRecipient(javax.mail.internet.MimeMessage smtpMessage)
static List<SimpleLink>
getFooterLinks(javax.mail.internet.MimeMessage message, String footerId)
static List<SimpleLink>
getLinksInElementWithId(javax.mail.internet.MimeMessage message, String id)
Locates all links inside a container with the specified id and returns them as an ordered list ofSimpleLink
s.static SimpleLink
getLinkWithId(javax.mail.internet.MimeMessage message, String id)
Locates a link with the specified id and returns it as aSimpleLink
.static SimpleLink
getLinkWithText(javax.mail.internet.MimeMessage message, String linkText)
Returns the first link that matches the provided link textstatic String
getPrefixedSubject(String subject)
static String
getSender(javax.mail.internet.MimeMessage smtpMessage)
Deprecated.since 7.6.0, useMailUtils.getSenders(Message)
) insteadstatic JSoupTester
getSoup(javax.mail.internet.MimeMessage message)
JSoup for you! Ask Fabian why this is better than using a DOM, or the plain text of the message body :)static com.google.common.base.Function<javax.mail.internet.MimeMessage,String>
toDiagnosticString()
static String
toDiagnosticString(javax.mail.internet.MimeMessage mimeMessage)
-
-
-
Method Detail
-
getBody
@Deprecated public static String getBody(javax.mail.internet.MimeMessage smtpMessage)
Deprecated.since 7.6.0, useMailUtils.getBody(Message)
-
getFirstRecipient
public static String getFirstRecipient(javax.mail.internet.MimeMessage smtpMessage)
-
getSender
@Deprecated public static String getSender(javax.mail.internet.MimeMessage smtpMessage) throws javax.mail.MessagingException
Deprecated.since 7.6.0, useMailUtils.getSenders(Message)
) instead- Throws:
javax.mail.MessagingException
-
getLinksInElementWithId
public static List<SimpleLink> getLinksInElementWithId(javax.mail.internet.MimeMessage message, String id)
Locates all links inside a container with the specified id and returns them as an ordered list ofSimpleLink
s. Will fail with a null-pointer exception if no matching node is found.- Parameters:
message
- the mime messageid
- the id to search for links within- Returns:
- a list of SimpleLink objects
-
getFooterLinks
public static List<SimpleLink> getFooterLinks(javax.mail.internet.MimeMessage message, String footerId)
-
getLinkWithId
public static SimpleLink getLinkWithId(javax.mail.internet.MimeMessage message, String id)
Locates a link with the specified id and returns it as aSimpleLink
. Will fail with a null-pointer exception if no matching node is found. ) content; }- Parameters:
message
- the mime message to search withinid
- the id of the link to return- Returns:
- a SimpleLink object
-
getLinkWithText
public static SimpleLink getLinkWithText(javax.mail.internet.MimeMessage message, String linkText)
Returns the first link that matches the provided link text- Parameters:
message
- the mime message to search withinlinkText
- the text of the link to match against to determine which link to return- Returns:
- a SimpleLink object if found, otherwise null
-
getSoup
public static JSoupTester getSoup(javax.mail.internet.MimeMessage message)
JSoup for you! Ask Fabian why this is better than using a DOM, or the plain text of the message body :)- Parameters:
message
- the message to get the HTML body from- Returns:
- a Jsoup test helper object
-
getDocument
public static Document getDocument(javax.mail.internet.MimeMessage message)
-
getEmailAddressedToUser
public static Iterable<javax.mail.internet.MimeMessage> getEmailAddressedToUser(User user, List<javax.mail.internet.MimeMessage> allMessages)
-
toDiagnosticString
public static com.google.common.base.Function<javax.mail.internet.MimeMessage,String> toDiagnosticString()
-
toDiagnosticString
public static String toDiagnosticString(javax.mail.internet.MimeMessage mimeMessage) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
extractFirstEmailAddressedTo
public static javax.mail.internet.MimeMessage extractFirstEmailAddressedTo(User user, List<javax.mail.internet.MimeMessage> allMessages)
-
filterBySubject
public static Collection<javax.mail.internet.MimeMessage> filterBySubject(Collection<javax.mail.internet.MimeMessage> messages, String subject)
-
-