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.MimeMessagejakarta.mail.internet.MimeMessagecreateMimeMessage(InputStream contentStream) protected PropertiesAllow Map access to the JavaMail properties of this sender, with the option to add or override specific entries.protected jakarta.mail.SessionReturn the JavaMailSession, lazily initializing it if hasn't been specified explicitly.voidsend(jakarta.mail.internet.MimeMessage mimeMessage) voidsend(jakarta.mail.internet.MimeMessage... mimeMessages) voidsend(MimeMessagePreparator mimeMessagePreparator) voidsend(MimeMessagePreparator... mimeMessagePreparators) voidsetDefaultEncoding(String defaultEncoding) Set the default encoding to use forMimeMessagescreated by this instance.voidsetDefaultFileTypeMap(jakarta.activation.FileTypeMap defaultFileTypeMap) Set the default Java ActivationFileTypeMapto use forMimeMessagescreated by this instance.voidsetJavaMailProperties(Properties javaMailProperties) Set JavaMail properties for theSession.voidsetSession(jakarta.mail.Session session) Set the JavaMailSession, possibly pulled from JNDI.Methods inherited from class io.awspring.cloud.ses.SimpleEmailServiceMailSender
destroy, getEmailService, getSourceArn, send, sendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
Sessionwill 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
Sessionwithout 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 forMimeMessagescreated 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 ActivationFileTypeMapto use forMimeMessagescreated by this instance.A
FileTypeMapspecified here will be autodetected byMimeMessageHelper, avoiding the need to specify theFileTypeMapfor eachMimeMessageHelperinstance.For example, you can specify a custom instance of Spring's
ConfigurableMimeFileTypeMaphere. If not explicitly specified, a defaultConfigurableMimeFileTypeMapwill be used, containing an extended set of MIME type mappings (as defined by themime.typesfile contained in the Spring jar).- Parameters:
defaultFileTypeMap- Java Activation file type map- See Also:
-
createMimeMessage
public jakarta.mail.internet.MimeMessage createMimeMessage()- Specified by:
createMimeMessagein interfaceJavaMailSender
-
createMimeMessage
public jakarta.mail.internet.MimeMessage createMimeMessage(InputStream contentStream) throws MailException - Specified by:
createMimeMessagein interfaceJavaMailSender- Throws:
MailException
-
send
- Specified by:
sendin interfaceJavaMailSender- Throws:
MailException
-
send
- Specified by:
sendin interfaceJavaMailSender- Throws:
MailException
-
send
- Specified by:
sendin interfaceJavaMailSender- Throws:
MailException
-
send
- Specified by:
sendin interfaceJavaMailSender- Throws:
MailException
-