Browse Source

try to make javamail use the specified port even when using SSL. Bugzilla Report 49267

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@943074 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 15 years ago
parent
commit
fdbe8c9fe5
4 changed files with 33 additions and 3 deletions
  1. +3
    -0
      WHATSNEW
  2. +9
    -3
      src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
  3. +17
    -0
      src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
  4. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java

+ 3
- 0
WHATSNEW View File

@@ -17,6 +17,9 @@ Changes that could break older environments:
Fixed bugs: Fixed bugs:
----------- -----------


* The MIME mailer ignored the port parameter when using SSL.
Bugzilla Report 49267.

Other changes: Other changes:
-------------- --------------




+ 9
- 3
src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java View File

@@ -69,7 +69,7 @@ public class EmailTask extends Task {
private String encoding = AUTO; private String encoding = AUTO;
/** host running SMTP */ /** host running SMTP */
private String host = "localhost"; private String host = "localhost";
private int port = SMTP_PORT;
private Integer port = null;
/** subject field */ /** subject field */
private String subject = null; private String subject = null;
/** any text */ /** any text */
@@ -161,7 +161,7 @@ public class EmailTask extends Task {
* @param port The port to use. * @param port The port to use.
*/ */
public void setMailport(int port) { 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 // pass the params to the mailer
mailer.setHost(host); 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.setUser(user);
mailer.setPassword(password); mailer.setPassword(password);
mailer.setSSL(ssl); mailer.setSSL(ssl);


+ 17
- 0
src/main/org/apache/tools/ant/taskdefs/email/Mailer.java View File

@@ -50,6 +50,7 @@ public abstract class Mailer {
// CheckStyle:VisibilityModifier ON // CheckStyle:VisibilityModifier ON
private boolean ignoreInvalidRecipients = false; private boolean ignoreInvalidRecipients = false;
private boolean starttls = false; private boolean starttls = false;
private boolean portExplicitlySpecified = false;


/** /**
* Set the mail server. * Set the mail server.
@@ -69,6 +70,22 @@ public abstract class Mailer {
this.port = port; this.port = port;
} }


/**
* 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. * Set the user for smtp auth.
* *


+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java View File

@@ -157,6 +157,10 @@ public class MimeMailer extends Mailer {
// SMTP provider // SMTP provider
props.put("mail.smtp.socketFactory.class", SSL_FACTORY); props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "false"); props.put("mail.smtp.socketFactory.fallback", "false");
if (isPortExplicitlySpecified()) {
props.put("mail.smtp.socketFactory.port",
String.valueOf(port));
}
} }
if (user != null || password != null) { if (user != null || password != null) {
props.put("mail.smtp.auth", "true"); props.put("mail.smtp.auth", "true");


Loading…
Cancel
Save