diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 6a848d39..e7ec9c49 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -959,10 +959,10 @@ public abstract class ExchangeSession { Set visibleRecipients = new HashSet(); Address[] recipients = mimeMessage.getAllRecipients(); for (Address address : recipients) { - visibleRecipients.add(address.toString()); + visibleRecipients.add(((InternetAddress)address).getAddress().toLowerCase()); } for (String recipient : rcptToRecipients) { - if (!visibleRecipients.contains(recipient)) { + if (!visibleRecipients.contains(recipient.toLowerCase())) { mimeMessage.addRecipient(javax.mail.Message.RecipientType.BCC, new InternetAddress(recipient)); } } diff --git a/src/test/davmail/smtp/TestSmtp.java b/src/test/davmail/smtp/TestSmtp.java index 9b8018bd..b02c0748 100644 --- a/src/test/davmail/smtp/TestSmtp.java +++ b/src/test/davmail/smtp/TestSmtp.java @@ -173,6 +173,15 @@ public class TestSmtp extends AbstractDavMailTestCase { sendAndCheckMessage(mimeMessage); } + public void testComplexToMessage() throws IOException, MessagingException, InterruptedException { + String body = "Test message"; + MimeMessage mimeMessage = new MimeMessage((Session) null); + mimeMessage.addHeader("To", "nickname <"+Settings.getProperty("davmail.to")+ '>'); + mimeMessage.setSubject("Test subject"); + mimeMessage.setText(body); + sendAndCheckMessage(mimeMessage); + } + public void testQuit() throws IOException { writeLine("QUIT"); assertEquals("221 Closing connection", readLine());