Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix JENKINS-9006
- Add support for partial sending like in MailSender
  • Loading branch information
slide committed Mar 24, 2012
1 parent 5f1e0c8 commit 72338a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/main/java/hudson/plugins/emailext/EmailExtensionPlugin.java
Expand Up @@ -62,6 +62,8 @@
import hudson.plugins.emailext.plugins.trigger.SuccessTrigger;
import hudson.plugins.emailext.plugins.trigger.UnstableTrigger;

import java.util.Arrays;

/**
* Entry point of a plugin.
*
Expand Down Expand Up @@ -131,4 +133,18 @@ private void addEmailTriggerPlugin(EmailTriggerDescriptor trigger) {
System.err.println(e.getMessage());
}
}

static {
// Fix JENKINS-9006
// When sending to multiple recipients, send to valid recipients even if some are
// invalid, unless we have explicitly said otherwise.

// we need this here as well as in the MailerTask because its possible we never actually
// use the MailerTask, which would mean it's static would never be called.
for (String property: Arrays.asList("mail.smtp.sendpartial", "mail.smtps.sendpartial")) {
if (System.getProperty(property) == null) {
System.setProperty(property, "true");
}
}
}
}
Expand Up @@ -325,22 +325,22 @@ public void testShouldSendEmailUsingUtf8ByDefault()
assertEquals( "We should an email since the build failed.", 1, mailbox.size() );
Message msg = mailbox.get(0);
assertThat( "Message should be multipart", msg.getContentType(),
containsString("multipart/mixed"));
containsString("multipart/mixed"));

// TODO: add more tests for getting the multipart information.
if(MimeMessage.class.isInstance(msg)) {
MimeMessage mimeMsg = (MimeMessage)msg;
assertEquals( "Message content should be a MimeMultipart instance",
MimeMultipart.class, mimeMsg.getContent().getClass());
MimeMultipart multipart = (MimeMultipart)mimeMsg.getContent();
assertTrue( "There should be at least one part in the email",
multipart.getCount() >= 1);
MimeBodyPart bodyPart = (MimeBodyPart) multipart.getBodyPart(0);
assertThat( "UTF-8 charset should be used.", bodyPart.getContentType(),
containsString( "charset=UTF-8" ) );
MimeMessage mimeMsg = (MimeMessage)msg;
assertEquals( "Message content should be a MimeMultipart instance",
MimeMultipart.class, mimeMsg.getContent().getClass());
MimeMultipart multipart = (MimeMultipart)mimeMsg.getContent();
assertTrue( "There should be at least one part in the email",
multipart.getCount() >= 1);
MimeBodyPart bodyPart = (MimeBodyPart) multipart.getBodyPart(0);
assertThat( "UTF-8 charset should be used.", bodyPart.getContentType(),
containsString( "charset=UTF-8" ) );
} else {
assertThat( "UTF-8 charset should be used.", mailbox.get( 0 ).getContentType(),
containsString( "charset=UTF-8" ) );
assertThat( "UTF-8 charset should be used.", mailbox.get( 0 ).getContentType(),
containsString( "charset=UTF-8" ) );
}
}

Expand Down

0 comments on commit 72338a0

Please sign in to comment.