Class SimpleEmailServiceJavaMailSender
- All Implemented Interfaces:
DisposableBean
,JavaMailSender
,MailSender
JavaMailSender
implementation that allows to send MimeMessage
using the Simple E-Mail Service. In
contrast to SimpleEmailServiceMailSender
this class also allows the use of attachment and other mime parts
inside mail messages.- Since:
- 1.0
- Author:
- Agim Emruli, EddĂș MelĂ©ndez, Arun Patra
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleEmailServiceJavaMailSender
(software.amazon.awssdk.services.ses.SesClient sesClient) SimpleEmailServiceJavaMailSender
(software.amazon.awssdk.services.ses.SesClient sesClient, String sourceArn) -
Method Summary
Modifier and TypeMethodDescriptionjakarta.mail.internet.MimeMessage
jakarta.mail.internet.MimeMessage
createMimeMessage
(InputStream contentStream) protected Properties
Allow Map access to the JavaMail properties of this sender, with the option to add or override specific entries.protected jakarta.mail.Session
Return the JavaMailSession
, lazily initializing it if hasn't been specified explicitly.void
send
(jakarta.mail.internet.MimeMessage mimeMessage) void
send
(jakarta.mail.internet.MimeMessage... mimeMessages) void
send
(MimeMessagePreparator mimeMessagePreparator) void
send
(MimeMessagePreparator... mimeMessagePreparators) void
setDefaultEncoding
(String defaultEncoding) Set the default encoding to use forMimeMessages
created by this instance.void
setDefaultFileTypeMap
(jakarta.activation.FileTypeMap defaultFileTypeMap) Set the default Java ActivationFileTypeMap
to use forMimeMessages
created by this instance.void
setJavaMailProperties
(Properties javaMailProperties) Set JavaMail properties for theSession
.void
setSession
(jakarta.mail.Session session) Set the JavaMailSession
, possibly pulled from JNDI.Methods inherited from class io.awspring.cloud.ses.SimpleEmailServiceMailSender
destroy, getEmailService, getSourceArn, send, send
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.mail.MailSender
send, send
-
Constructor Details
-
SimpleEmailServiceJavaMailSender
public SimpleEmailServiceJavaMailSender(software.amazon.awssdk.services.ses.SesClient sesClient) -
SimpleEmailServiceJavaMailSender
-
-
Method Details
-
getJavaMailProperties
Allow Map access to the JavaMail properties of this sender, with the option to add or override specific entries.Useful for specifying entries directly, for example via "javaMailProperties[mail.from]".
- Returns:
- java mail properties
-
setJavaMailProperties
Set JavaMail properties for theSession
.A new
Session
will be created with those properties.Non-default properties in this instance will override given JavaMail properties.
- Parameters:
javaMailProperties
- java mail props
-
getSession
Return the JavaMailSession
, lazily initializing it if hasn't been specified explicitly.- Returns:
- cached session or a new one from java mail properties
-
setSession
public void setSession(jakarta.mail.Session session) Set the JavaMailSession
, possibly pulled from JNDI.Default is a new
Session
without defaults, that is completely configured via this instance's properties.If using a pre-configured
Session
, non-default properties in this instance will override the settings in theSession
.- Parameters:
session
- JavaMail session- See Also:
-
setDefaultEncoding
Set the default encoding to use forMimeMessages
created by this instance.Such an encoding will be auto-detected by
MimeMessageHelper
.- Parameters:
defaultEncoding
- default encoding for mime messages
-
setDefaultFileTypeMap
public void setDefaultFileTypeMap(jakarta.activation.FileTypeMap defaultFileTypeMap) Set the default Java ActivationFileTypeMap
to use forMimeMessages
created by this instance.A
FileTypeMap
specified here will be autodetected byMimeMessageHelper
, avoiding the need to specify theFileTypeMap
for eachMimeMessageHelper
instance.For example, you can specify a custom instance of Spring's
ConfigurableMimeFileTypeMap
here. If not explicitly specified, a defaultConfigurableMimeFileTypeMap
will be used, containing an extended set of MIME type mappings (as defined by themime.types
file contained in the Spring jar).- Parameters:
defaultFileTypeMap
- Java Activation file type map- See Also:
-
createMimeMessage
public jakarta.mail.internet.MimeMessage createMimeMessage()- Specified by:
createMimeMessage
in interfaceJavaMailSender
-
createMimeMessage
public jakarta.mail.internet.MimeMessage createMimeMessage(InputStream contentStream) throws MailException - Specified by:
createMimeMessage
in interfaceJavaMailSender
- Throws:
MailException
-
send
- Specified by:
send
in interfaceJavaMailSender
- Throws:
MailException
-
send
- Specified by:
send
in interfaceJavaMailSender
- Throws:
MailException
-
send
- Specified by:
send
in interfaceJavaMailSender
- Throws:
MailException
-
send
- Specified by:
send
in interfaceJavaMailSender
- Throws:
MailException
-