public boolean isMailSendConfigOk() { getMailSessionLocalSettingsConfigModel(); return mailSendConfigOk; }
/** * @return true if at least a send mail host is given, otherwise false. */ @Override public boolean isSendMailConfigured() { return sendMailConfiguration != null && sendMailConfiguration.isMailSendConfigOk(); }
final String subject = composedMessage.getSubject(); final SendMailConfig sendMailConfig = configurationService.getSendMailConfiguration(); message.setSubject(subject, sendMailConfig.getCharset()); message.setSentDate(new Date()); message.setText(composedMessage.getContent(), composedMessage.getCharset(), composedMessage.getContentType()); } else { message.setText(composedMessage.getContent(), sendMailConfig.getCharset());
private void sendProactiveMessageToSupportTeam() { if (StringUtils.isBlank(configService.getPfSupportMailAddress()) == Boolean.FALSE && configService.getSendMailConfiguration() != null) { log.info("Sending proactive mail to support."); Calendar cal = Calendar.getInstance(); Date date = cal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm"); String dateString = formatter.format(date); SendFeedbackData errorData = new SendFeedbackData(); errorData.setSender(configService.getSendMailConfiguration().getDefaultSendMailAddress()); errorData.setReceiver(configService.getPfSupportMailAddress()); errorData.setSubject("Error occured: #" + form.data.getMessageNumber() + " on " + configService.getDomain()); errorData.setDescription("Error occured at: " + dateString + "(" + cal.getTimeZone().getID() + ") with number: #" + form.data.getMessageNumber() + " from user: " + form.data.getSender() + " \n " + "Exception stack trace: \n" + form.data.getRootCauseStackTrace() + "\n"); sendFeedback.send(errorData); } else { log.info("No messaging for proactive support configured."); } }
@Test public void sendMailSyncWithIcalAndAttachmentTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = "ABC"; final Collection<MailAttachment> attachments = new ArrayList<>(); when(attachment.getFilename()).thenReturn("test.abc"); sendMail.send(message, icalContent, attachments, false); }
@Test public void sendMailSyncWithAttachmentTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = null; final Collection<MailAttachment> attachments = new ArrayList<>(); when(attachment.getFilename()).thenReturn("test.abc"); attachments.add(attachment); sendMail.send(message, icalContent, attachments, false); }
public String getDefaultSendMailAddress() { return getMailSessionLocalSettingsConfigModel().getDefaultEmailSender(); }
@Test public void sendMailSyncTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = null; final Collection<? extends MailAttachment> attachments = null; sendMail.send(message, icalContent, attachments, false); }
@Test public void sendMailSyncWithIcalTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = "ABC"; final Collection<? extends MailAttachment> attachments = null; sendMail.send(message, icalContent, attachments, false); }
} else { type = "text/html; charset="; type += sendMailConfig.getCharset();
@Test public void sendMailSyncNullContentTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); final String icalContent = null; final Collection<? extends MailAttachment> attachments = null; try { sendMail.send(message, icalContent, attachments, false); assertTrue(false); } catch (InternalErrorException e) { //OK //java.lang.NullPointerException: null //at com.sun.mail.handlers.text_plain.writeTo(text_plain.java:152) } }