use of com.autentia.tnt.mail.DefaultMailService in project TNTConcept by autentia.
the class SiiBean method sendReportEmail.
public void sendReportEmail(String report) {
if (report != null) {
Map<InputStream, String> attachments = new ConcurrentHashMap<>();
String filename = reportName();
attachments.put(getStreamReport(report), filename);
String subject = "SII_" + filename.split(".csv")[0];
ExecutorService executor = Executors.newFixedThreadPool(1);
// Runnable, return void, submit and run the task async
executor.submit(() -> {
try {
String[] recipients = to.trim().split("[;,]");
MailService mailService = (DefaultMailService) SpringUtils.getSpringBean("mailService");
mailService.sendOutputStreams(recipients, subject, "", attachments);
context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Email enviado correctamente", null));
} catch (MessagingException e) {
System.err.println(e.getMessage());
}
});
executor.shutdown();
}
}
use of com.autentia.tnt.mail.DefaultMailService in project TNTConcept by autentia.
the class RequestHolidayBean method sendEmail.
protected void sendEmail() {
final DefaultMailService mailService = (DefaultMailService) SpringUtils.getSpringBean("mailService");
final Collection<String> mailSendToHolidayApprovers = ConfigurationUtil.getDefault().getMailSendToHolidayApprovers();
for (String sendTo : mailSendToHolidayApprovers) {
final String name = this.search.getUserRequest().getName();
String subject = "Solicitud de vacaciones para " + name;
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy" + "");
final String beginDate = dateFormat.format(this.requestHoliday.getBeginDate());
final String finalDate = dateFormat.format(this.requestHoliday.getFinalDate());
final String newLine = "</div><div>";
String messageBody = ("<div>Usuario: ").concat("<b>" + name + "</b>").concat(newLine).concat("Fecha de inicio: ").concat("<b>" + beginDate + "</b>").concat(newLine).concat("Fecha de fin: ").concat("<b>" + finalDate + "</b>").concat(newLine).concat("Comentarios: ").concat(this.requestHoliday.getUserComment()).concat(newLine);
mailService.sendHtml(sendTo, subject, messageBody);
}
}
use of com.autentia.tnt.mail.DefaultMailService in project TNTConcept by autentia.
the class AdminHolidayBean method sendEmail.
protected void sendEmail() {
final DefaultMailService mailService = (DefaultMailService) SpringUtils.getSpringBean("mailService");
final Collection<String> mailNotificationReceivers = new ArrayList<String>(ConfigurationUtil.getDefault().getMailSendToHolidayApprovers());
mailNotificationReceivers.add(this.adminHoliday.getUserRequest().getEmail());
for (String sendTo : mailNotificationReceivers) {
final String name = this.adminHoliday.getUserRequest().getName();
String subject = "Solicitud de vacaciones de " + name + "[" + getState() + "]";
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy" + "");
final String beginDate = dateFormat.format(this.adminHoliday.getBeginDate());
final String finalDate = dateFormat.format(this.adminHoliday.getFinalDate());
final String newLine = "</div><div>";
String messageBody = ("<div>Usuario: ").concat("<b>" + name + "</b>").concat(newLine).concat("Fecha de inicio: ").concat("<b>" + beginDate + "</b>").concat(newLine).concat("Fecha de fin: ").concat("<b>" + finalDate + "</b>").concat(newLine).concat("Comentarios: ").concat(this.adminHoliday.getUserComment()).concat(newLine);
mailService.sendHtml(sendTo, subject, messageBody);
}
}
use of com.autentia.tnt.mail.DefaultMailService in project TNTConcept by autentia.
the class LinkBean method sendMail.
public void sendMail(Link link, String mailAddress) {
DefaultMailService mailService = getMailService();
try {
ExternalContext externalContext = getFacesExternalContext();
HttpServletRequest req = (HttpServletRequest) externalContext.getRequest();
String verificationLink = buildResetPasswordVerificationLink(req, link);
mailService.send(mailAddress, "[RESETEO DE CONTRASEÑA] Email de verificación", "Haz click en el siguiente link para verificar que eres tú si quieres cambiar la contraseña: " + verificationLink);
} catch (MessagingException e) {
e.printStackTrace();
}
}
use of com.autentia.tnt.mail.DefaultMailService in project TNTConcept by autentia.
the class UserBean method resetPassword.
/**
* Reset current user password
*
* @return "userPasswordReset"
*/
public String resetPassword() {
// get random words from properties, depending on locale
String[] rnd0 = FacesUtils.formatMessage("AuthenticationManager.randomWords0").split(",");
String[] rnd1 = FacesUtils.formatMessage("AuthenticationManager.randomWords1").split(",");
String[] rnd2 = FacesUtils.formatMessage("AuthenticationManager.randomWords2").split(",");
String[] rnd3 = FacesUtils.formatMessage("AuthenticationManager.randomWords3").split(",");
String[] rnd4 = FacesUtils.formatMessage("AuthenticationManager.randomWords4").split(",");
// Change user password
changedPassword = authManager.resetPassword(user, rnd0, rnd1, rnd2, rnd3, rnd4);
if (!ConfigurationUtil.getDefault().isLdapProviderEnabled()) {
manager.updateEntity(user, this.isUseAgreementYearDuration());
}
DefaultMailService mailService = (DefaultMailService) SpringUtils.getSpringBean("mailService");
try {
mailService.send(user.getEmail(), "Reseteo de contraseña de TnT", "Tu nueva contraseña es: " + changedPassword);
} catch (MessagingException e) {
log.warn(e.getCause());
}
return "userPasswordReset";
}
Aggregations