diff options
Diffstat (limited to 'plugins')
2 files changed, 6 insertions, 5 deletions
diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java index 115191d9394..6079b20228e 100644 --- a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java +++ b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java @@ -19,6 +19,9 @@ */ package org.sonar.plugins.emailnotifications; +import java.net.MalformedURLException; +import java.net.URL; + import org.apache.commons.lang.StringUtils; import org.apache.commons.mail.EmailException; import org.apache.commons.mail.SimpleEmail; @@ -32,9 +35,6 @@ import org.sonar.api.utils.SonarException; import org.sonar.plugins.emailnotifications.api.EmailMessage; import org.sonar.plugins.emailnotifications.api.EmailTemplate; -import java.net.MalformedURLException; -import java.net.URL; - /** * References: * <ul> @@ -163,7 +163,8 @@ public class EmailNotificationChannel extends NotificationChannel { } // Set general information email.setCharset("UTF-8"); - email.setFrom(configuration.getFrom(), StringUtils.defaultIfBlank(emailMessage.getFrom(), FROM_NAME_DEFAULT)); + String from = StringUtils.isBlank(emailMessage.getFrom()) ? FROM_NAME_DEFAULT : emailMessage.getFrom() + " (Sonar)"; + email.setFrom(configuration.getFrom(), from); email.addTo(emailMessage.getTo(), " "); String subject = StringUtils.defaultIfBlank(StringUtils.trimToEmpty(configuration.getPrefix()) + " ", "") + StringUtils.defaultString(emailMessage.getSubject(), SUBJECT_DEFAULT); diff --git a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java index 0dc4182d0b3..b02fbf86001 100644 --- a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java +++ b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/EmailNotificationChannelTest.java @@ -142,7 +142,7 @@ public class EmailNotificationChannelTest { assertThat(email.getHeaderValue("List-ID"), is("Sonar <sonar.nemo.sonarsource.org>")); assertThat(email.getHeaderValue("List-Archive"), is("http://nemo.sonarsource.org")); - assertThat(email.getHeaderValue("From"), is("Full Username <server@nowhere>")); + assertThat(email.getHeaderValue("From"), is("\"Full Username (Sonar)\" <server@nowhere>")); assertThat(email.getHeaderValue("To"), is("<user@nowhere>")); assertThat(email.getHeaderValue("Subject"), is("[SONAR] Review #3")); assertThat(email.getBody(), is("I'll take care of this violation.")); |