Package com.chatmotorapi.api.notify
Class EmailNotificationChannel
java.lang.Object
com.chatmotorapi.api.notify.EmailNotificationChannel
- All Implemented Interfaces:
NotificationChannel
public class EmailNotificationChannel extends Object implements NotificationChannel
The EmailNotificationChannel class handles sending emails as part of response post-treatment processes.
It provides methods to send emails with or without attachments either synchronously or asynchronously,
depending on the specified ExecutionMode.
Usage
To create an instance of EmailNotificationChannel, use the nested EmailNotificationChannel.Builder class.
The following fields are required:
- smtpHost: The SMTP server host address.
- smtpPort: The SMTP server port number.
- smtpUsername: The username for SMTP authentication.
- smtpPassword: The password for SMTP authentication.
- fromAddress: The sender's email address.
- toAddress: The recipient's email address.
- subject: The subject of the email.
- message: The HTML content of the email message.
Optional field:
- logger: A custom
Loggerinstance for logging operations. If not provided, a default logger will be used.
Example:
EmailNotificationChannel emailNotificationChannel = new EmailNotificationChannel.Builder()
.chatMotor(chatmotor)
.smtpHost("smtp.example.com")
.smtpPort(587)
.smtpUsername("your-username")
.smtpPassword("your-password")
.fromAddress("from@example.com")
.toAddress("to@example.com")
.subject("Email Subject")
.message("<h1>Hello World</h1>")
.logger(LoggerFactory.getLogger(YourClass.class))
.build();
After building the instance, you can use the notifyDocumentAvailable and dispatchDocument
methods to send emails with or without attachments.
- See Also:
EmailNotificationChannel.Builder
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEmailNotificationChannel.BuilderBuilder class forEmailNotificationChannel. -
Method Summary
Modifier and Type Method Description MotorNotifyResponsedispatchDocument(String filePath, ExecutionMode mode)Sends the generated response document to the user.MotorNotifyResponsenotifyDocumentAvailable(String filePath, ExecutionMode mode)Notifies the user that a response document is available.
-
Method Details
-
notifyDocumentAvailable
Description copied from interface:NotificationChannelNotifies the user that a response document is available.- Specified by:
notifyDocumentAvailablein interfaceNotificationChannel- Parameters:
filePath- the file path of the response document that is availablemode- the execution mode, either synchronous (SYNC) or asynchronous (ASYNC)- Returns:
- a MotorNotifyResponse object containing the result of the notification process
-
dispatchDocument
Description copied from interface:NotificationChannelSends the generated response document to the user.- Specified by:
dispatchDocumentin interfaceNotificationChannel- Parameters:
filePath- the file path of the response document to be sentmode- the execution mode, either synchronous (SYNC) or asynchronous (ASYNC)- Returns:
- a MotorNotifyResponse object containing the result of the document dispatch process
-