*/
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;
import org.sonar.plugins.emailnotifications.api.EmailMessage;
import org.sonar.plugins.emailnotifications.api.EmailTemplate;
-import java.net.MalformedURLException;
-import java.net.URL;
-
/**
* References:
* <ul>
}
// 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);
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."));