private EmailMessage()

in notification/src/main/java/org/opensearch/alerting/destination/message/EmailMessage.java [29:72]


    private EmailMessage(final DestinationType destinationType,
                         final String destinationName,
                         final String host,
                         final Integer port,
                         final String method,
                         final String from,
                         final List<String> recipients,
                         final String subject,
                         final SecureString username,
                         final SecureString password,
                         final String message) {

        super(destinationType, destinationName, message);

        if (DestinationType.EMAIL != destinationType) {
            throw new IllegalArgumentException("Channel Type does not match Email");
        }

        if (Strings.isNullOrEmpty(message)) {
            throw new IllegalArgumentException("Message content is missing");
        }

        if(Strings.isNullOrEmpty(host)) {
            throw new IllegalArgumentException("Host name should be provided");
        }

        if(Strings.isNullOrEmpty(from)) {
            throw new IllegalArgumentException("From address should be provided");
        }

        if(recipients == null || recipients.isEmpty()) {
            throw new IllegalArgumentException("List of recipients should be provided");
        }

        this.message = message;
        this.host = host;
        this.port = port == null ? 25 : port;
        this.method = method == null ? "none" : method;
        this.from = from;
        this.recipients = recipients;
        this.subject = subject == "" ? destinationName : subject;
        this.username = username;
        this.password = password;
    }