mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
adding support for reply-to header
This commit is contained in:
1 parent
e5c96723f3
commit
5bef34ce61
3 files changed
+36
No files matched your search
@@ -38,6 +38,9 @@ import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
@@ -310,6 +313,11 @@ public class MailSender {
|
||||
msg.setContent("", "text/plain");
|
||||
msg.setFrom(new InternetAddress(Mailer.descriptor().getAdminAddress()));
|
||||
msg.setSentDate(new Date());
|
||||
|
||||
String replyTo = Mailer.descriptor().getReplyToAddress();
|
||||
if (StringUtils.isNotBlank(replyTo)) {
|
||||
msg.setHeader("Reply-To", replyTo);
|
||||
}
|
||||
|
||||
Set<InternetAddress> rcp = new LinkedHashSet<InternetAddress>();
|
||||
String defaultSuffix = Mailer.descriptor().getDefaultSuffix();
|
||||
|
||||
@@ -40,6 +40,14 @@ import hudson.model.UserPropertyDescriptor;
|
||||
import hudson.util.FormValidation;
|
||||
import hudson.util.Secret;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.tools.ant.types.selectors.SelectorUtils;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
@@ -171,6 +179,20 @@ public class Mailer extends Notifier {
|
||||
*/
|
||||
private String adminAddress;
|
||||
|
||||
/**
|
||||
* The e-mail address that Hudson puts to "Reply-To" header in outgoing e-mails.
|
||||
* Null if not configured.
|
||||
*/
|
||||
private String replyToAddress;
|
||||
|
||||
public String getReplyToAddress() {
|
||||
return replyToAddress;
|
||||
}
|
||||
|
||||
public void setReplyToAddress(String address) {
|
||||
this.replyToAddress = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* The SMTP server to use for sending e-mail. Null for default to the environment,
|
||||
* which is usually <tt>localhost</tt>.
|
||||
@@ -450,6 +472,9 @@ public class Mailer extends Notifier {
|
||||
msg.setSubject(Messages.Mailer_TestMail_Subject(++testEmailCount), charset);
|
||||
msg.setText(Messages.Mailer_TestMail_Content(testEmailCount, Jenkins.getInstance().getDisplayName()), charset);
|
||||
msg.setFrom(new InternetAddress(adminAddress));
|
||||
if (StringUtils.isNotBlank(replyToAddress)) {
|
||||
msg.setHeader("Reply-To", replyToAddress);
|
||||
}
|
||||
msg.setSentDate(new Date());
|
||||
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(sendTestMailTo));
|
||||
|
||||
|
||||
Reference in new issue
Block a user