提交 59ec56d7 编写于 作者: N Nolan Lawson 提交者: Kohsuke Kawaguchi

Use default suffix for outgoing addresses in MailSender, when they don't contain a '@'

上级 c93ed1de
......@@ -58,6 +58,9 @@ Upcoming changes</a>
<li class="bug">
Fixed a bug in the symlink creation code on BSD platforms.
<a href="https://issues.jenkins-ci.org/browse/JENKINS-12119">issue 12119</a>
<li class="bug">
Default e-mail suffix should be used to complete the domain name portion of the recipients list.
(<a href="https://github.com/jenkinsci/jenkins/pull/324">pull #324</a>)
<li class="bug">
Incorrect path delimiter used in ZipArchiver when creating archive on Windows.
<a href="https://issues.jenkins-ci.org/browse/JENKINS-9942">issue 9942</a>
......
......@@ -312,6 +312,7 @@ public class MailSender {
msg.setSentDate(new Date());
Set<InternetAddress> rcp = new LinkedHashSet<InternetAddress>();
String defaultSuffix = Mailer.descriptor().getDefaultSuffix();
StringTokenizer tokens = new StringTokenizer(recipients);
while (tokens.hasMoreTokens()) {
String address = tokens.nextToken();
......@@ -326,10 +327,17 @@ public class MailSender {
includeCulpritsOf(up, build, listener, rcp);
} else {
// ordinary address
// if not a valid address (i.e. no '@'), then try adding suffix
if (!address.contains("@") && defaultSuffix != null && defaultSuffix.contains("@")) {
address += defaultSuffix;
}
try {
rcp.add(new InternetAddress(address));
} catch (AddressException e) {
// report bad address, but try to send to other addresses
listener.getLogger().println("Unable to send to address: " + address);
e.printStackTrace(listener.error(e.getMessage()));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册