All Downloads are FREE. Search and download functionalities are using the official Maven repository.

BPMLeaveRequestIT.tasks.mail-util.ts Maven / Gradle / Ivy

The newest version!
import { configurations } from "sdk/core";
import { logging } from "sdk/log";
import { client as mailClient } from "sdk/mail";

const logger = logging.getLogger("mail-util.ts");

function isMailConfigured() {
    return configurations.get("MAIL_USERNAME", "user") &&
        configurations.get("MAIL_PASSWORD", "password") &&
        configurations.get("MAIL_TRANSPORT_PROTOCOL", "smtp") &&
        (
//             (configurations.get("MAIL_SMTPS_HOST", "localhost") && configurations.get("MAIL_SMTPS_PORT", PortUtil.getFreeRandomPort()) && configurations.get("MAIL_SMTPS_AUTH", "true"))
//             ||
            (configurations.get("MAIL_SMTP_HOST", "localhost") && configurations.get("MAIL_SMTP_PORT", "56565") && configurations.get("DIRIGIBLE_MAIL_SMTP_AUTH", "true"))
        );
}

export function sendMail(to: string, subject: string, content: string) {
    const from = configurations.get("LEAVE_REQUEST_APP_FROM_EMAIL", "[email protected]");

    if (isMailConfigured()) {
        logger.info("Sending mail to [{}] with subject [{}] and content: [{}]...", to, subject, content);
        mailClient.send(from, to, subject, content, 'html');
    } else {
        logger.info("Mail to [{}] with subject [{}] and content [{}] will NOT be send because the mail client is not configured.", to, subject, content);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy