diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 14a698b45..288171837 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -48,6 +48,7 @@ Conor MacNeill
Craeg Strong
Craig Cottingham
Craig R. McClanahan
+Craig Richardson
Craig Ryan
Craig Sandvik
Curtis White
diff --git a/WHATSNEW b/WHATSNEW
index 8826f188f..490580edb 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -482,6 +482,10 @@ Other changes:
.
Bugzilla Report 27419.
+ * MailLogger and can now optionally enable support for
+ STARTTLS.
+ Bugzilla Report 46063.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
diff --git a/contributors.xml b/contributors.xml
index 8d8d9d26c..6e654d11d 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -219,6 +219,10 @@
Craig
Ryan
+
+ Craig
+ Richardson
+
Craig
Sandvik
diff --git a/docs/manual/CoreTasks/mail.html b/docs/manual/CoreTasks/mail.html
index c119cd24c..def6c0c37 100644
--- a/docs/manual/CoreTasks/mail.html
+++ b/docs/manual/CoreTasks/mail.html
@@ -179,6 +179,14 @@
fail if neither is reachable. Since Ant 1.8.0.
No, default is false |
+
+ enableStartTLS |
+ "true", "on" or "yes" accepted here
+ whether the STARTTLS command used to switch to an encrypted
+ connection for authentication should be supported. Requires
+ JavaMail. Since Ant 1.8.0 |
+ No |
+
Note regarding the attributes containing email addresses
diff --git a/docs/manual/listeners.html b/docs/manual/listeners.html
index 7175cd225..c44d0f16f 100644
--- a/docs/manual/listeners.html
+++ b/docs/manual/listeners.html
@@ -245,6 +245,12 @@ control for turning off success or failure messages individually.
Character set of the message. Since Ant 1.8.0 |
No |
+
+ MailLogger.starttls.enable |
+ on or true if STARTTLS should be supported
+ (requires JavaMail). Since Ant 1.8.0 |
+ No, default is false |
+
MailLogger.properties.file |
Filename of properties file that will override other values. |
diff --git a/src/main/org/apache/tools/ant/listener/MailLogger.java b/src/main/org/apache/tools/ant/listener/MailLogger.java
index 8623f2885..870a99a06 100644
--- a/src/main/org/apache/tools/ant/listener/MailLogger.java
+++ b/src/main/org/apache/tools/ant/listener/MailLogger.java
@@ -73,6 +73,8 @@ import org.apache.tools.mail.MailMessage;
* mail body for a successful build, default is to send the logfile
* MailLogger.mimeType [default: text/plain] - MIME-Type of email
* MailLogger.charset [no default] - character set of email
+ * Maillogger.starttls.enable [default: false] - on or true if
+ * STARTTLS should be supported (requires JavaMail)
* MailLogger.properties.file [no default] - Filename of
* properties file that will override other values.
*
@@ -142,6 +144,8 @@ public class MailLogger extends DefaultLogger {
.password(getValue(properties, "password", ""))
.ssl(Project.toBoolean(getValue(properties,
"ssl", "off")))
+ .starttls(Project.toBoolean(getValue(properties,
+ "starttls.enable", "off")))
.from(getValue(properties, "from", null))
.replytoList(getValue(properties, "replyto", ""))
.toList(getValue(properties, prefix + ".to", null))
@@ -153,7 +157,7 @@ public class MailLogger extends DefaultLogger {
(success) ? "Build Success" : "Build Failure"));
if (values.user().equals("")
&& values.password().equals("")
- && !values.ssl()) {
+ && !values.ssl() && !values.starttls()) {
sendMail(values, buffer.substring(0));
} else {
sendMimeMail(
@@ -262,6 +266,14 @@ public class MailLogger extends DefaultLogger {
this.body = body;
return this;
}
+ private boolean starttls;
+ public boolean starttls() {
+ return starttls;
+ }
+ public Values starttls(boolean starttls) {
+ this.starttls = starttls;
+ return this;
+ }
}
/**
@@ -365,6 +377,7 @@ public class MailLogger extends DefaultLogger {
mailer.setUser(values.user());
mailer.setPassword(values.password());
mailer.setSSL(values.ssl());
+ mailer.setEnableStartTLS(values.ssl());
Message mymessage =
new Message(values.body().length() > 0 ? values.body() : message);
mymessage.setProject(project);
diff --git a/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java b/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
index 6360f0562..9eb03d44d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
@@ -102,6 +102,8 @@ public class EmailTask extends Task {
private String password = null;
/** indicate if the user wishes SSL-TLS */
private boolean ssl = false;
+ /** indicate if the user wishes support for STARTTLS */
+ private boolean starttls = false;
/** ignore invalid recipients? */
private boolean ignoreInvalidRecipients = false;
@@ -133,6 +135,16 @@ public class EmailTask extends Task {
this.ssl = ssl;
}
+ /**
+ * Set whether to allow authentication to switch to a TLS
+ * connection via STARTTLS.
+ * @param b boolean; if true STARTTLS will be supported.
+ * @since Ant 1.8.0
+ */
+ public void setEnableStartTLS(boolean b) {
+ this.starttls = b;
+ }
+
/**
* Set the preferred encoding method.
*
@@ -454,9 +466,10 @@ public class EmailTask extends Task {
throw new BuildException("SMTP auth only possible with MIME mail");
}
// SSL only allowed with MIME mail
- if (!autoFound && (ssl)
+ if (!autoFound && (ssl || starttls)
&& (encoding.equals(UU) || encoding.equals(PLAIN))) {
- throw new BuildException("SSL only possible with MIME mail");
+ throw new BuildException("SSL and STARTTLS only possible with"
+ + " MIME mail");
}
// try UU format
if (encoding.equals(UU)
@@ -537,6 +550,7 @@ public class EmailTask extends Task {
mailer.setUser(user);
mailer.setPassword(password);
mailer.setSSL(ssl);
+ mailer.setEnableStartTLS(starttls);
mailer.setMessage(message);
mailer.setFrom(from);
mailer.setReplyToList(replyToList);
diff --git a/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java b/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
index bb9cf7e2d..5a0d3e4cc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
@@ -49,6 +49,7 @@ public abstract class Mailer {
protected Vector headers = null;
// CheckStyle:VisibilityModifier ON
private boolean ignoreInvalidRecipients = false;
+ private boolean starttls = false;
/**
* Set the mail server.
@@ -98,6 +99,20 @@ public abstract class Mailer {
this.SSL = ssl;
}
+ /**
+ * Set whether to allow authentication to switch to a TLS
+ * connection via STARTTLS.
+ * @param b boolean; if true STARTTLS will be supported.
+ * @since Ant 1.8.0
+ */
+ public void setEnableStartTLS(boolean b) {
+ this.starttls = b;
+ }
+
+ protected boolean isStartTLSEnabled() {
+ return starttls;
+ }
+
/**
* Set the message.
*
diff --git a/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java b/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
index 4a295d3e6..931345281 100644
--- a/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
@@ -161,6 +161,9 @@ public class MimeMailer extends Mailer {
props.put("mail.smtp.auth", "true");
auth = new SimpleAuthenticator(user, password);
}
+ if (isStartTLSEnabled()) {
+ props.put("mail.smtp.starttls.enable", "true");
+ }
sesh = Session.getInstance(props, auth);
//create the message