ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r943074 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java src/main/org/apache/tools/ant/taskdefs/email/Mailer.java src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
Date Tue, 11 May 2010 10:27:05 GMT
Author: bodewig
Date: Tue May 11 10:27:04 2010
New Revision: 943074

URL: http://svn.apache.org/viewvc?rev=943074&view=rev
Log:
try to make javamail use the specified port even when using SSL.  Bugzilla Report 49267

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=943074&r1=943073&r2=943074&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue May 11 10:27:04 2010
@@ -17,6 +17,9 @@ Changes that could break older environme
 Fixed bugs:
 -----------
 
+ * The MIME mailer ignored the port parameter when using SSL.
+   Bugzilla Report 49267.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java?rev=943074&r1=943073&r2=943074&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java Tue May 11
10:27:04 2010
@@ -69,7 +69,7 @@ public class EmailTask extends Task {
     private String encoding = AUTO;
     /** host running SMTP  */
     private String host = "localhost";
-    private int port = SMTP_PORT;
+    private Integer port = null;
     /** subject field  */
     private String subject = null;
     /** any text  */
@@ -161,7 +161,7 @@ public class EmailTask extends Task {
      * @param port The port to use.
      */
     public void setMailport(int port) {
-        this.port = port;
+        this.port = Integer.valueOf(port);
     }
 
     /**
@@ -549,7 +549,13 @@ public class EmailTask extends Task {
 
             // pass the params to the mailer
             mailer.setHost(host);
-            mailer.setPort(port);
+            if (port != null) {
+                mailer.setPort(port.intValue());
+                mailer.setPortExplicitlySpecified(true);
+            } else {
+                mailer.setPort(SMTP_PORT);
+                mailer.setPortExplicitlySpecified(false);
+            }
             mailer.setUser(user);
             mailer.setPassword(password);
             mailer.setSSL(ssl);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java?rev=943074&r1=943073&r2=943074&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java Tue May 11 10:27:04
2010
@@ -50,6 +50,7 @@ public abstract class Mailer {
     // CheckStyle:VisibilityModifier ON
     private boolean ignoreInvalidRecipients = false;
     private boolean starttls = false;
+    private boolean portExplicitlySpecified = false;
 
     /**
      * Set the mail server.
@@ -70,6 +71,22 @@ public abstract class Mailer {
     }
 
     /**
+     * Whether the port has been explicitly specified by the user. 
+     * @since Ant 1.8.2
+     */
+    public void setPortExplicitlySpecified(boolean explicit) {
+        portExplicitlySpecified = explicit;
+    }
+
+    /**
+     * Whether the port has been explicitly specified by the user. 
+     * @since Ant 1.8.2
+     */
+    protected boolean isPortExplicitlySpecified() {
+        return portExplicitlySpecified;
+    }
+
+    /**
      * Set the user for smtp auth.
      *
      * @param user the username.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java?rev=943074&r1=943073&r2=943074&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java Tue May 11
10:27:04 2010
@@ -157,6 +157,10 @@ public class MimeMailer extends Mailer {
                 // SMTP provider
                 props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
                 props.put("mail.smtp.socketFactory.fallback", "false");
+                if (isPortExplicitlySpecified()) {
+                    props.put("mail.smtp.socketFactory.port",
+                              String.valueOf(port));
+                }
             }
             if (user != null || password != null) {
                 props.put("mail.smtp.auth", "true");



Mime
View raw message