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

dev.ditsche.mjml.MailBuilder Maven / Gradle / Ivy

package dev.ditsche.mjml;

import java.util.HashMap;

/**
 * @author Tobias Dittmann
 */
public final class MailBuilder {

    private String subject;

    private MailAddress recipient;

    private HashMap params;

    private MailBuilder(String subject) {
        this.params = new HashMap<>();
        this.subject = subject;
    }

    public static MailBuilder create(String subject) {
        return new MailBuilder(subject);
    }

    public MailBuilder to(MailAddress recipient) {
        this.recipient = recipient;
        return this;
    }

    public MailBuilder param(String key, Object value) {
        this.params.put(key, value);
        return this;
    }

    public Mail template(String path) {
        Mail mail = Mail.fromTemplate(this.subject, path, this.params);
        mail.addRecipient(this.recipient);
        return mail;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy