-
- /**
- * Sends a summary mail to the user.
- *
- * @param aText
- * Text of the mail.
- * @throws MessagingException
- * In case of problems sending mail.
- */
- private void sendMail(ProgramActionExecutor aExecutor) throws MessagingException {
- String textReport = aExecutor.getReport();
- System.out.println("Text report: \n" + textReport);
- System.out.println("XML report:\n" + aExecutor.getXmlReport().asXML());
-
-
- Properties props = new Properties();
- props.put("mail.transport.protocol", "smtp");
- props.put("mail.smtp.host", "falcon");
- props.put("mail.smtp.port", "25");
-
- Session mailSession = Session.getInstance(props);
- InternetAddress from = new InternetAddress("erik@brakkee.org");
-
- HtmlEmail mail = new HtmlEmail();
- mail.setMailSession(mailSession);
- try {
- mail.setFrom("erik@brakkee.org");
- mail.setTo(Arrays.asList(new InternetAddress[] { from }));
- mail.setSentDate(new Date());
- mail.setSubject("KiSS Crawler Update");
- String html = aExecutor.getXmlReport().asXML();
- Document document = new XSLT().transform(html.getBytes(), new FileResource(new File("reportToHtml.xsl")));
- ByteArrayOutputStream xhtml = new ByteArrayOutputStream();
- XMLSerializer serializer = new XMLSerializer(xhtml, new OutputFormat());
- serializer.serialize(document);
- mail.setHtmlMsg(xhtml.toString());
- mail.setTextMsg(textReport);
- mail.send();
- } catch (EmailException e) {
- throw new RuntimeException(e);
- } catch (TransformerException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-