/** * Setup the comment e-mail * * @param blog {@link Blog} information * @param entry {@link Entry} * @param email Email message * @throws EmailException If there is an error preparing the e-mail message */ protected void setupEmail(Blog blog, Entry entry, Email email) throws EmailException { email.setCharset(BlojsomConstants.UTF8); // If we have a mail session for the environment, use that if (_session != null) { email.setMailSession(_session); } else { // Otherwise, if there is a username and password for the mail server, use that if (!BlojsomUtils.checkNullOrBlank(_mailServerUsername) && !BlojsomUtils.checkNullOrBlank(_mailServerPassword)) { email.setHostName(_mailServer); email.setAuthentication(_mailServerUsername, _mailServerPassword); } else { email.setHostName(_mailServer); } } email.setFrom(blog.getBlogOwnerEmail(), "Blojsom Comment"); String author = entry.getAuthor(); if (BlojsomUtils.checkNullOrBlank(author)) { author = blog.getBlogOwner(); } String authorEmail = blog.getBlogOwnerEmail(); if (author != null) { try { User user = _fetcher.loadUser(blog, author); if (user == null) { authorEmail = blog.getBlogOwnerEmail(); } else { authorEmail = user.getUserEmail(); if (BlojsomUtils.checkNullOrBlank(authorEmail)) { authorEmail = blog.getBlogOwnerEmail(); } } } catch (FetcherException e) { } } email.addTo(authorEmail, author); email.setSentDate(new Date()); }