Class EmailNotificationService

java.lang.Object
cf.maybelambda.httpvalidator.springboot.service.EmailNotificationService

@Service public class EmailNotificationService extends Object
Service to send email notifications using external SMTP service.
  • Constructor Details

    • EmailNotificationService

      public EmailNotificationService(@Value("${mailer.apikey}") String apiKey)
  • Method Details

    • sendVTaskErrorsNotification

      public void sendVTaskErrorsNotification(@NonNull List<String[]> mailBody) throws ConnectIOException
      Sends a notification email with validation task failure results.
      Parameters:
      mailBody - A list of validation task failure results.
      Throws:
      ConnectIOException - If an error occurs while sending the email.
    • sendAppTerminatedNotification

      public void sendAppTerminatedNotification(String endTime) throws ConnectIOException
      Sends a notification email about application termination.
      Parameters:
      endTime - The end time of the application.
      Throws:
      ConnectIOException - If an error occurs while sending the email.
    • isValidConfig

      public boolean isValidConfig()
      Checks if the email configuration is valid.

      This method verifies that the necessary properties for sending emails are properly configured in the environment. Specifically, it checks:

      • The "notifications.from" property, which should contain the sender's email address.
      • The "notifications.to" property, which should contain the recipient's email address.
      • The "mailer.apikey" property, which should contain the API key for authentication with SMTP service.
      If any of these properties are blank or missing, the configuration is considered invalid.
      Returns:
      True if all necessary properties are set and non-blank, false otherwise.