private boolean sendEmail(UserModel user, X509Metadata metadata, File zip) {
// send email
try {
if (mail.isReady()) {
Mailing mailing = Mailing.newPlain();
mailing.subject = "Your Gitblit client certificate for " + metadata.serverHostname;
mailing.setRecipients(user.emailAddress);
String body = X509Utils.processTemplate(new File(folder, X509Utils.CERTS + File.separator + "mail.tmpl"), metadata);
if (StringUtils.isEmpty(body)) {
body = MessageFormat.format("Hi {0}\n\nHere is your client certificate bundle.\nInside the zip file are installation instructions.", user.getDisplayName());
}
mailing.content = body;
mailing.addAttachment(zip);
Message message = mail.createMessage(mailing);
mail.sendNow(message);
return true;