Do not use javax.mail for doCheckAdminAddress (#6166)

This commit is contained in:
Jesse Glick authored and GitHub committed 2022-01-07 06:27:12 -08:00
1 parent 46d6af94e6
commit 72d38d2192
2 files changed
+5 -6

No files matched your search

@@ -18,8 +18,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.servlet.ServletContext;
import jenkins.util.SystemProperties;
import jenkins.util.UrlHelper;
@@ -210,11 +208,11 @@ public class JenkinsLocationConfiguration extends GlobalConfiguration implements
}
public FormValidation doCheckAdminAddress(@QueryParameter String value) {
try {
new InternetAddress(value);
// TODO if equal to Messages.Mailer_Address_Not_Configured(), suggest configuring it with FormValidation.warning?
if (Util.fixNull(value).contains("@")) {
return FormValidation.ok();
} catch (AddressException e) {
return FormValidation.error(e.getMessage());
} else {
return FormValidation.error(Messages.JenkinsLocationConfiguration_does_not_look_like_an_email_address());
}
}