Package org.jgrapes.mail
Class SystemMailSender
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.mail.MailComponent
org.jgrapes.mail.SystemMailSender
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
A component that sends mail using a system wide (user independant)
configuration to access the server.
The component uses Jakarta Mail to connect to a mail server.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Fields inherited from class org.jgrapes.mail.MailComponent
mailProps
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new component with its channel set to itself.SystemMailSender
(Channel componentChannel) Creates a new component base with its channel set to the given channel.SystemMailSender
(Channel componentChannel, HandlerDefinition.ChannelReplacements channelReplacements) Creates a new component base like#SimpleMailSender(Channel)
but with channel mappings forHandler
annotations. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureComponent
(Map<String, String> values) Configure the component specific values.Returns the max idle time.void
onMessage
(SendMessage event) Sends the message as specified by the event.void
Start the component.void
Stop the monitor.setMailProperties
(Map<String, String> props) Sets the mail properties.setMaxIdleTime
(Duration maxIdleTime) Sets the maximum idle time.Methods inherited from class org.jgrapes.mail.MailComponent
onConfigUpdate, password, setPassword, toString
Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SystemMailSender
public SystemMailSender()Creates a new component with its channel set to itself. -
SystemMailSender
Creates a new component base with its channel set to the given channel.As a special case
Channel.SELF
can be passed to the constructor to make the component use itself as channel. The special value is necessary as you obviously cannot pass an object to be constructed to its constructor.- Parameters:
componentChannel
- the channel that the component’s handlers listen on by default and thatManager.fire(Event, Channel...)
sends the event to
-
SystemMailSender
public SystemMailSender(Channel componentChannel, HandlerDefinition.ChannelReplacements channelReplacements) Creates a new component base like#SimpleMailSender(Channel)
but with channel mappings forHandler
annotations.- Parameters:
componentChannel
- the channel that the component’s handlers listen on by default and thatManager.fire(Event, Channel...)
sends the event tochannelReplacements
- the channel replacements to apply to thechannels
elements of theHandler
annotations
-
-
Method Details
-
setMailProperties
Sets the mail properties.See the Jakarta Mail documentation for available settings.
- Overrides:
setMailProperties
in classMailComponent
- Parameters:
props
- the props- Returns:
- the mail monitor
-
setMaxIdleTime
Sets the maximum idle time.An open connection to the mail server is closed after this time.
- Parameters:
maxIdleTime
- the new max idle time
-
maxIdleTime
Returns the max idle time.- Returns:
- the duration
-
configureComponent
Description copied from class:MailComponent
Configure the component specific values.- Specified by:
configureComponent
in classMailComponent
- Parameters:
values
- the values
-
onStart
Start the component.- Parameters:
event
- the event- Throws:
MessagingException
-
onMessage
Sends the message as specified by the event.- Parameters:
event
- the event- Throws:
MessagingException
- the messaging exception
-
onStop
Stop the monitor.- Parameters:
event
- the event- Throws:
MessagingException
-