use of com.gitblit.models.Mailing in project gitblit by gitblit.
the class NotificationManager method sendHtmlMail.
/**
* Notify users by email of something.
*
* @param subject
* @param message
* @param toAddresses
*/
@Override
public void sendHtmlMail(String subject, String message, Collection<String> toAddresses) {
Mailing mail = Mailing.newHtml();
mail.subject = subject;
mail.content = message;
mail.setRecipients(toAddresses);
send(mail);
}
use of com.gitblit.models.Mailing in project gitblit by gitblit.
the class NotificationManager method sendMailToAdministrators.
/**
* Notify the administrators by email.
*
* @param subject
* @param message
*/
@Override
public void sendMailToAdministrators(String subject, String message) {
Mailing mail = Mailing.newPlain();
mail.subject = subject;
mail.content = message;
mail.setRecipients(settings.getStrings(Keys.mail.adminAddresses));
send(mail);
}
use of com.gitblit.models.Mailing in project gitblit by gitblit.
the class GitblitAuthority method sendEmail.
private boolean sendEmail(UserModel user, X509Metadata metadata, File zip) {
// send email
try {
if (mail.isReady()) {
Mailing mailing = Mailing.newPlain();
if (user.getPreferences().getLocale() != null)
mailing.subject = MessageFormat.format(ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", user.getPreferences().getLocale()).getString("gb.emailClientCertificateSubject"), metadata.serverHostname);
else
mailing.subject = MessageFormat.format(ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", Locale.ENGLISH).getString("gb.emailClientCertificateSubject"), metadata.serverHostname);
mailing.setRecipients(user.emailAddress);
File fileMailTmp = null;
String body = null;
if ((fileMailTmp = new File(folder, X509Utils.CERTS + File.separator + "mail.tmpl" + "_" + user.getPreferences().getLocale())).exists())
body = X509Utils.processTemplate(fileMailTmp, metadata);
else {
fileMailTmp = new File(folder, X509Utils.CERTS + File.separator + "mail.tmpl");
body = X509Utils.processTemplate(fileMailTmp, 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;
} else {
JOptionPane.showMessageDialog(GitblitAuthority.this, "Sorry, the mail server settings are not configured properly.\nCan not send email.", Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);
}
} catch (Exception e) {
Utils.showException(GitblitAuthority.this, e);
}
return false;
}
use of com.gitblit.models.Mailing in project gitblit by gitblit.
the class TicketNotifier method queueMailing.
/**
* Queues an update notification.
*
* @param ticket
* @return a notification object used for testing
*/
public Mailing queueMailing(TicketModel ticket) {
try {
// format notification message
String markdown = formatLastChange(ticket);
StringBuilder html = new StringBuilder();
html.append("<head>");
html.append(readStyle());
html.append(readViewTicketAction(ticket));
html.append("</head>");
html.append("<body>");
html.append(MarkdownUtils.transformGFM(settings, markdown, ticket.repository));
html.append("</body>");
Mailing mailing = Mailing.newHtml();
mailing.from = getUserModel(ticket.updatedBy == null ? ticket.createdBy : ticket.updatedBy).getDisplayName();
mailing.subject = getSubject(ticket);
mailing.content = html.toString();
mailing.id = "ticket." + ticket.number + "." + StringUtils.getSHA1(ticket.repository + ticket.number);
setRecipients(ticket, mailing);
queue.put(ticket.number, mailing);
return mailing;
} catch (Exception e) {
Logger.getLogger(getClass()).error("failed to queue mailing for #" + ticket.number, e);
}
return null;
}
use of com.gitblit.models.Mailing in project gitblit by gitblit.
the class NotificationManager method sendMail.
/**
* Notify users by email of something.
*
* @param subject
* @param message
* @param toAddresses
*/
@Override
public void sendMail(String subject, String message, Collection<String> toAddresses) {
Mailing mail = Mailing.newPlain();
mail.subject = subject;
mail.content = message;
mail.setRecipients(toAddresses);
send(mail);
}
Aggregations