use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class EmailServerUtil method applyMacrosToEmail.
static EmailItemBean applyMacrosToEmail(final EmailItemBean emailItem, final MacroMachine macroMachine) {
final EmailItemBean expandedEmailItem;
expandedEmailItem = new EmailItemBean(macroMachine.expandMacros(emailItem.getTo()), macroMachine.expandMacros(emailItem.getFrom()), macroMachine.expandMacros(emailItem.getSubject()), macroMachine.expandMacros(emailItem.getBodyPlain()), macroMachine.expandMacros(emailItem.getBodyHtml()));
return expandedEmailItem;
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class PasswordUtility method sendNewPasswordEmail.
private static ErrorInformation sendNewPasswordEmail(final UserInfo userInfo, final PwmApplication pwmApplication, final MacroMachine macroMachine, final PasswordData newPassword, final String toAddress, final Locale userLocale) throws PwmOperationalException, PwmUnrecoverableException {
final Configuration config = pwmApplication.getConfig();
final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_SENDPASSWORD, userLocale);
if (configuredEmailSetting == null) {
final String errorMsg = "send password email contents are not configured";
return new ErrorInformation(PwmError.ERROR_UNKNOWN, errorMsg);
}
final EmailItemBean emailItemBean = new EmailItemBean(configuredEmailSetting.getTo(), configuredEmailSetting.getFrom(), configuredEmailSetting.getSubject(), configuredEmailSetting.getBodyPlain().replace("%TOKEN%", newPassword.getStringValue()), configuredEmailSetting.getBodyHtml().replace("%TOKEN%", newPassword.getStringValue()));
pwmApplication.getEmailQueue().submitEmail(emailItemBean, userInfo, macroMachine);
LOGGER.debug("new password email to " + userInfo.getUserIdentity() + " added to send queue for " + toAddress);
return null;
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class DeleteAccountServlet method sendProfileUpdateEmailNotice.
private static void sendProfileUpdateEmailNotice(final PwmRequest pwmRequest) throws PwmUnrecoverableException, ChaiUnavailableException {
final Configuration config = pwmRequest.getConfig();
final Locale locale = pwmRequest.getLocale();
final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_DELETEACCOUNT, locale);
if (configuredEmailSetting == null) {
LOGGER.debug(pwmRequest, "skipping delete account notice email for '" + pwmRequest.getUserInfoIfLoggedIn() + "' no email configured");
return;
}
pwmRequest.getPwmApplication().getEmailQueue().submitEmail(configuredEmailSetting, pwmRequest.getPwmSession().getUserInfo(), pwmRequest.getPwmSession().getSessionManager().getMacroMachine(pwmRequest.getPwmApplication()));
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class GuestRegistrationServlet method sendGuestUserEmailConfirmation.
private void sendGuestUserEmailConfirmation(final PwmRequest pwmRequest, final UserIdentity userIdentity) throws PwmUnrecoverableException {
final PwmSession pwmSession = pwmRequest.getPwmSession();
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final Configuration config = pwmApplication.getConfig();
final Locale locale = pwmSession.getSessionStateBean().getLocale();
final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_GUEST, locale);
if (configuredEmailSetting == null) {
LOGGER.debug(pwmSession, "unable to send guest registration email for '" + userIdentity + "' no email configured");
return;
}
final MacroMachine macroMachine = MacroMachine.forUser(pwmRequest, userIdentity);
pwmApplication.getEmailQueue().submitEmail(configuredEmailSetting, null, macroMachine);
}
use of password.pwm.bean.EmailItemBean in project pwm by pwm-project.
the class ForgottenUsernameServlet method sendUsername.
private void sendUsername(final PwmApplication pwmApplication, final PwmSession pwmSession, final UserInfo forgottenUserInfo) throws PwmOperationalException, PwmUnrecoverableException {
final Locale userLocale = pwmSession.getSessionStateBean().getLocale();
final Configuration configuration = pwmApplication.getConfig();
final MessageSendMethod messageSendMethod = configuration.readSettingAsEnum(PwmSetting.FORGOTTEN_USERNAME_SEND_USERNAME_METHOD, MessageSendMethod.class);
final EmailItemBean emailItemBean = configuration.readSettingAsEmail(PwmSetting.EMAIL_SEND_USERNAME, userLocale);
final String smsMessage = configuration.readSettingAsLocalizedString(PwmSetting.SMS_FORGOTTEN_USERNAME_TEXT, userLocale);
if (messageSendMethod == null || messageSendMethod == MessageSendMethod.NONE) {
return;
}
sendMessageViaMethod(pwmApplication, pwmSession.getLabel(), forgottenUserInfo, messageSendMethod, emailItemBean, smsMessage);
}
Aggregations