public class MailerHelper extends Object
Mailer.| Constructor and Description |
|---|
MailerHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
scanForInjectionAttack(@Nullable String value,
String valueLabel) |
static void |
scanForInjectionAttacks(@NotNull org.simplejavamail.api.email.Email email)
Checks the following headers for suspicious content (newlines and characters):
subject
every header name and value
every attachment name, nested datasource name and description
every embedded image name, nested datasource name and description
from recipient name and address
replyTo recipient name and address, if provided
bounceTo recipient name and address, if provided
every TO/CC/BCC recipient name and address
disposition-notification-to recipient name and address, if provided
return-receipt-to recipient name and address, if provided
|
static jakarta.mail.internet.MimeMessage |
signAndOrEncryptMessageWithSmime(@NotNull jakarta.mail.Session session,
@NotNull jakarta.mail.internet.MimeMessage messageToProtect,
@NotNull org.simplejavamail.api.email.Email emailContainingSmimeDetails,
@Nullable org.simplejavamail.api.mailer.config.Pkcs12Config defaultSmimeSigningStore)
Depending on the Email configuration, signs and then encrypts message (both steps optional), using the S/MIME module.
|
static jakarta.mail.internet.MimeMessage |
signMessageWithDKIM(@NotNull jakarta.mail.internet.MimeMessage messageToSign,
@NotNull org.simplejavamail.api.email.Email emailContainingSigningDetails) |
static boolean |
validate(@NotNull org.simplejavamail.api.email.Email email,
@Nullable com.sanctionco.jmail.EmailValidator emailValidator)
Delegates to all other validations for a full checkup.
|
static void |
validateAddresses(@NotNull org.simplejavamail.api.email.Email email,
@Nullable com.sanctionco.jmail.EmailValidator emailValidator)
If email validator is provided, checks:
from recipient
all TO/CC/BCC recipients
reply-to recipient, if provided
bounce-to recipient, if provided
disposition-notification-to recipient, if provided
return-receipt-to recipient, if provided
|
static void |
validateCompleteness(@NotNull org.simplejavamail.api.email.Email email)
Checks whether:
there are recipients
if there is a sender
if there is a disposition notification TO if flag is set to use it
if there is a return receipt TO if flag is set to use it
|
static boolean |
validateLenient(@NotNull org.simplejavamail.api.email.Email email,
@Nullable com.sanctionco.jmail.EmailValidator emailValidator)
Lenient validation only checks for missing fields (which implies incorrect configuration or missing data),
but only warns for invalid address and suspected CRLF injections.
|
public static boolean validate(@NotNull
@NotNull org.simplejavamail.api.email.Email email,
@Nullable
@Nullable com.sanctionco.jmail.EmailValidator emailValidator)
throws org.simplejavamail.MailException
org.simplejavamail.MailExceptionvalidateCompleteness(Email),
validateAddresses(Email, EmailValidator),
scanForInjectionAttacks(Email)public static boolean validateLenient(@NotNull
@NotNull org.simplejavamail.api.email.Email email,
@Nullable
@Nullable com.sanctionco.jmail.EmailValidator emailValidator)
throws org.simplejavamail.MailException
org.simplejavamail.MailExceptionvalidateCompleteness(Email),
validateAddresses(Email, EmailValidator),
scanForInjectionAttacks(Email)public static void validateCompleteness(@NotNull
@NotNull org.simplejavamail.api.email.Email email)
public static void validateAddresses(@NotNull
@NotNull org.simplejavamail.api.email.Email email,
@Nullable
@Nullable com.sanctionco.jmail.EmailValidator emailValidator)
public static void scanForInjectionAttacks(@NotNull
@NotNull org.simplejavamail.api.email.Email email)
public static void scanForInjectionAttack(@Nullable
@Nullable String value,
String valueLabel)
value - Value checked for suspicious newline characters "\n", "\r" and the URL-encoded newline "%0A" (as acknowledged by SMTP servers).valueLabel - The name of the field being checked, used for reporting exceptions.public static jakarta.mail.internet.MimeMessage signMessageWithDKIM(@NotNull
@NotNull jakarta.mail.internet.MimeMessage messageToSign,
@NotNull
@NotNull org.simplejavamail.api.email.Email emailContainingSigningDetails)
DKIMModule.signMessageWithDKIM(MimeMessage, DkimConfig, Recipient)public static jakarta.mail.internet.MimeMessage signAndOrEncryptMessageWithSmime(@NotNull
@NotNull jakarta.mail.Session session,
@NotNull
@NotNull jakarta.mail.internet.MimeMessage messageToProtect,
@NotNull
@NotNull org.simplejavamail.api.email.Email emailContainingSmimeDetails,
@Nullable
@Nullable org.simplejavamail.api.mailer.config.Pkcs12Config defaultSmimeSigningStore)
SMIMEModule.signAndOrEncryptEmail(Session, MimeMessage, Email, Pkcs12Config)Copyright © 2009–2023. All rights reserved.