Search in sources :

Example 1 with SendSmtpEmailRequest

use of io.lumeer.core.task.executor.request.SendSmtpEmailRequest in project engine by Lumeer.

the class LumeerBridge method sendEmail.

@SuppressWarnings("unused")
public void sendEmail(final String to, final String fromName, final String subject, final String body, final LinkBridge l, final String attrId, final Value smtpConfig) throws Exception {
    if (task.getDaoContextSnapshot().increaseEmailCounter() <= Task.MAX_EMAILS) {
        if (StringUtils.isNotEmpty(to) && to.split(",").length > Task.MAX_EMAIL_RECIPIENTS) {
            cause = new IllegalStateException("Too many email recipients (more than 100).");
            throw cause;
        }
        final SmtpConfiguration smtpConfiguration = getSmtpConfiguration(smtpConfig);
        if (smtpConfiguration != null) {
            final SendSmtpEmailRequest sendSmtpEmailRequest = new SendSmtpEmailRequest(subject, to, body, fromName, smtpConfiguration);
            registerAttachment(sendSmtpEmailRequest, l, attrId);
            operations.add(new SendSmtpEmailOperation(sendSmtpEmailRequest));
        }
    } else {
        cause = new IllegalStateException("Too many requests to send email in a single rule (more than 3).");
        throw cause;
    }
}
Also used : SendSmtpEmailRequest(io.lumeer.core.task.executor.request.SendSmtpEmailRequest) SendSmtpEmailOperation(io.lumeer.core.task.executor.operation.SendSmtpEmailOperation) SmtpConfiguration(io.lumeer.core.task.executor.request.SmtpConfiguration)

Example 2 with SendSmtpEmailRequest

use of io.lumeer.core.task.executor.request.SendSmtpEmailRequest in project engine by Lumeer.

the class LumeerBridge method sendEmail.

@SuppressWarnings("unused")
public void sendEmail(final String to, final String fromName, final String subject, final String body, final DocumentBridge d, final String attrId, final Value smtpConfig) throws Exception {
    if (task.getDaoContextSnapshot().increaseEmailCounter() <= Task.MAX_EMAILS) {
        if (StringUtils.isNotEmpty(to)) {
            if (to.split(",").length > Task.MAX_EMAIL_RECIPIENTS) {
                cause = new IllegalStateException("Too many email recipients (more than 100).");
                throw cause;
            }
            final SmtpConfiguration smtpConfiguration = getSmtpConfiguration(smtpConfig);
            if (smtpConfiguration != null) {
                final SendSmtpEmailRequest sendSmtpEmailRequest = new SendSmtpEmailRequest(subject, to, body, fromName, smtpConfiguration);
                registerAttachment(sendSmtpEmailRequest, d, attrId);
                operations.add(new SendSmtpEmailOperation(sendSmtpEmailRequest));
            }
        } else {
            cause = new IllegalStateException("Recipients list is empty.");
            throw cause;
        }
    } else {
        cause = new IllegalStateException("Too many requests to send email in a single rule (more than 3).");
        throw cause;
    }
}
Also used : SendSmtpEmailRequest(io.lumeer.core.task.executor.request.SendSmtpEmailRequest) SendSmtpEmailOperation(io.lumeer.core.task.executor.operation.SendSmtpEmailOperation) SmtpConfiguration(io.lumeer.core.task.executor.request.SmtpConfiguration)

Example 3 with SendSmtpEmailRequest

use of io.lumeer.core.task.executor.request.SendSmtpEmailRequest in project engine by Lumeer.

the class LumeerBridge method sendEmail.

@SuppressWarnings("unused")
public void sendEmail(final String to, final String fromName, final String subject, final String body, final Value smtpConfig) {
    if (task.getDaoContextSnapshot().increaseEmailCounter() <= Task.MAX_EMAILS) {
        final SmtpConfiguration smtpConfiguration = getSmtpConfiguration(smtpConfig);
        if (smtpConfiguration != null) {
            final SendSmtpEmailRequest sendSmtpEmailRequest = new SendSmtpEmailRequest(subject, to, body, fromName, smtpConfiguration);
            operations.add(new SendSmtpEmailOperation(sendSmtpEmailRequest));
        }
    }
}
Also used : SendSmtpEmailRequest(io.lumeer.core.task.executor.request.SendSmtpEmailRequest) SendSmtpEmailOperation(io.lumeer.core.task.executor.operation.SendSmtpEmailOperation) SmtpConfiguration(io.lumeer.core.task.executor.request.SmtpConfiguration)

Aggregations

SendSmtpEmailOperation (io.lumeer.core.task.executor.operation.SendSmtpEmailOperation)3 SendSmtpEmailRequest (io.lumeer.core.task.executor.request.SendSmtpEmailRequest)3 SmtpConfiguration (io.lumeer.core.task.executor.request.SmtpConfiguration)3