Index: plugins/email-ext/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java =================================================================== --- plugins/email-ext/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java (revision 9668) +++ plugins/email-ext/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java (working copy) @@ -411,11 +411,17 @@ private String smtpHost; /** - * If true use SSL on port 465 (standard SMTPS). + * If true use SSL on port 465 (standard SMTPS) unless smtpPort is set. */ private boolean useSsl; /** + * The SMTP port to use for sending e-mail. Null for default to the environment, + * which is usually 25. + */ + private String smtpPort; + + /** * This is a global default subject line for sending emails. */ private String defaultSubject; @@ -445,6 +451,9 @@ Properties props = new Properties(System.getProperties()); if(smtpHost!=null) props.put("mail.smtp.host",smtpHost); + if (smtpPort!=null) { + props.put("mail.smtp.port", smtpPort); + } if (useSsl) { /* This allows the user to override settings by setting system properties but * also allows us to use the default SMTPs port of 465 if no port is already set. @@ -454,8 +463,9 @@ */ props.put("mail.smtp.auth","true"); if (props.getProperty("mail.smtp.socketFactory.port") == null) { - props.put("mail.smtp.port", "465"); - props.put("mail.smtp.socketFactory.port", "465"); + String port = smtpPort==null?"465":smtpPort; + props.put("mail.smtp.port", port); + props.put("mail.smtp.socketFactory.port", port); } if (props.getProperty("mail.smtp.socketFactory.class") == null) { props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory"); @@ -495,6 +505,10 @@ return useSsl; } + public String getSmtpPort() { + return smtpPort; + } + public String getDefaultBody() { return defaultBody; } @@ -578,6 +592,9 @@ //specify if the mail server uses ssl for authentication useSsl = req.getParameter("ext_mailer_smtp_use_ssl")!=null; + //specify custom smtp port + smtpPort = nullify(req.getParameter("ext_mailer_smtp_port")); + //Allow global defaults to be set for the subject and body of the email defaultSubject = nullify(req.getParameter("ext_mailer_default_subject")); defaultBody = nullify(req.getParameter("ext_mailer_default_body")); Index: plugins/email-ext/src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/global.jelly =================================================================== --- plugins/email-ext/src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/global.jelly (revision 9668) +++ plugins/email-ext/src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/global.jelly (working copy) @@ -36,6 +36,11 @@ help="/help/tasks/mailer/smtp-use-ssl.html"> + + + smtpPort is set. */ private boolean useSsl; /** + * The SMTP port to use for sending e-mail. Null for default to the environment, + * which is usually 25. + */ + private String smtpPort; + + /** * Used to keep track of number test e-mails. */ private static transient int testEmailCount = 0; @@ -178,6 +184,9 @@ Properties props = new Properties(System.getProperties()); if(smtpHost!=null) props.put("mail.smtp.host",smtpHost); + if (smtpPort!=null) { + props.put("mail.smtp.port", smtpPort); + } if (useSsl) { /* This allows the user to override settings by setting system properties but * also allows us to use the default SMTPs port of 465 if no port is already set. @@ -186,8 +195,9 @@ * coordinate, and we can make it work through setting mail.smtp properties. */ if (props.getProperty("mail.smtp.socketFactory.port") == null) { - props.put("mail.smtp.port", "465"); - props.put("mail.smtp.socketFactory.port", "465"); + String port = smtpPort==null?"465":smtpPort; + props.put("mail.smtp.port", port); + props.put("mail.smtp.socketFactory.port", port); } if (props.getProperty("mail.smtp.socketFactory.class") == null) { props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory"); @@ -231,6 +241,7 @@ } else { smtpAuthUsername = smtpAuthPassword = null; } + smtpPort = nullify(req.getParameter("mailer_smtp_port")); useSsl = req.getParameter("mailer_smtp_use_ssl")!=null; save(); return super.configure(req); @@ -267,6 +278,10 @@ return useSsl; } + public String getSmtpPort() { + return smtpPort; + } + public Publisher newInstance(StaplerRequest req) { Mailer m = new Mailer(); req.bindParameters(m,"mailer_"); Index: main/core/src/main/resources/hudson/tasks/Mailer/global.jelly =================================================================== --- main/core/src/main/resources/hudson/tasks/Mailer/global.jelly (revision 9668) +++ main/core/src/main/resources/hudson/tasks/Mailer/global.jelly (working copy) @@ -43,6 +43,11 @@ help="/help/tasks/mailer/smtp-use-ssl.html"> + + + \ No newline at end of file Index: main/war/resources/help/tasks/mailer/smtp-port.html =================================================================== --- main/war/resources/help/tasks/mailer/smtp-port.html (revision 0) +++ main/war/resources/help/tasks/mailer/smtp-port.html (revision 0) @@ -0,0 +1,3 @@ +
+ Port number for the mail server. Leave it empty to use the default port for the protocol. +
\ No newline at end of file