Search in sources :

Example 1 with Mail

use of org.jreleaser.model.Mail in project jreleaser by jreleaser.

the class MailAnnouncer method announce.

@Override
public void announce() throws AnnounceException {
    Mail mail = context.getModel().getAnnounce().getMail();
    String message = "";
    if (isNotBlank(mail.getMessage())) {
        message = mail.getResolvedMessage(context);
    } else {
        Map<String, Object> props = new LinkedHashMap<>();
        props.put(Constants.KEY_CHANGELOG, MustacheUtils.passThrough(context.getChangelog()));
        context.getModel().getRelease().getGitService().fillProps(props, context.getModel());
        message = mail.getResolvedMessageTemplate(context, props);
    }
    String subject = mail.getResolvedSubject(context);
    context.getLogger().info("subject: {}", subject);
    context.getLogger().debug("message: {}", message);
    try {
        MessageMailCommand.builder(context.getLogger()).dryrun(context.isDryrun()).transport(mail.getTransport()).host(mail.getHost()).port(mail.getPort()).auth(mail.isAuth()).username(mail.getUsername()).password(context.isDryrun() ? "**UNDEFINED**" : mail.getResolvedPassword()).from(mail.getFrom()).to(mail.getTo()).cc(mail.getCc()).bcc(mail.getBcc()).subject(subject).message(message).mimeType(mail.getMimeType()).build().execute();
    } catch (MailException e) {
        context.getLogger().trace(e);
        throw new AnnounceException(e);
    }
}
Also used : AnnounceException(org.jreleaser.model.announcer.spi.AnnounceException) Mail(org.jreleaser.model.Mail) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 Mail (org.jreleaser.model.Mail)1 AnnounceException (org.jreleaser.model.announcer.spi.AnnounceException)1