From 4fcac9d2cbdafb51e3ee9ca3b3da64fd86103174 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Tue, 26 Nov 2013 15:58:15 -0500 Subject: [PATCH] Remove artifact setting from manager dialog --- src/main/java/com/gitblit/MailExecutor.java | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gitblit/MailExecutor.java b/src/main/java/com/gitblit/MailExecutor.java index 54ff8b8..b1ba3b6 100644 --- a/src/main/java/com/gitblit/MailExecutor.java +++ b/src/main/java/com/gitblit/MailExecutor.java @@ -41,9 +41,9 @@ /** * The mail executor handles sending email messages asynchronously from queue. - * + * * @author James Moger - * + * */ public class MailExecutor implements Runnable { @@ -60,6 +60,7 @@ final String mailUser = settings.getString(Keys.mail.username, null); final String mailPassword = settings.getString(Keys.mail.password, null); + final boolean smtps = settings.getBoolean(Keys.mail.smtps, false); boolean authenticate = !StringUtils.isEmpty(mailUser) && !StringUtils.isEmpty(mailPassword); String server = settings.getString(Keys.mail.server, ""); if (StringUtils.isEmpty(server)) { @@ -79,7 +80,7 @@ props.setProperty("mail.smtp.auth", String.valueOf(authenticate)); props.setProperty("mail.smtp.auths", String.valueOf(authenticate)); - if (isGMail) { + if (isGMail || smtps) { props.setProperty("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.socketFactory.port", String.valueOf(port)); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); @@ -89,6 +90,7 @@ if (!StringUtils.isEmpty(mailUser) && !StringUtils.isEmpty(mailPassword)) { // SMTP requires authentication session = Session.getInstance(props, new Authenticator() { + @Override protected PasswordAuthentication getPasswordAuthentication() { PasswordAuthentication passwordAuthentication = new PasswordAuthentication( mailUser, mailPassword); @@ -103,7 +105,7 @@ /** * Indicates if the mail executor can send emails. - * + * * @return true if the mail executor is ready to send emails */ public boolean isReady() { @@ -113,7 +115,7 @@ /** * Create a message. - * + * * @param toAddresses * @return a message */ @@ -123,7 +125,7 @@ /** * Create a message. - * + * * @param toAddresses * @return a message */ @@ -142,7 +144,7 @@ for (String address : toAddresses) { uniques.add(address.toLowerCase()); } - + Pattern validEmail = Pattern .compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); List<InternetAddress> tos = new ArrayList<InternetAddress>(); @@ -156,7 +158,7 @@ } catch (Throwable t) { } } - } + } message.setRecipients(Message.RecipientType.BCC, tos.toArray(new InternetAddress[tos.size()])); message.setSentDate(new Date()); @@ -168,7 +170,7 @@ /** * Returns the status of the mail queue. - * + * * @return true, if the queue is empty */ public boolean hasEmptyQueue() { @@ -177,7 +179,7 @@ /** * Queue's an email message to be sent. - * + * * @param message * @return true if the message was queued */ @@ -212,13 +214,13 @@ failures.add(message); } } - + // push the failures back onto the queue for the next cycle queue.addAll(failures); } } } - + public void sendNow(Message message) throws Exception { Transport.send(message); } -- Gitblit v1.9.1