From 889673e3e3390c5bfd0627c2dc4035a4a7d27906 Mon Sep 17 00:00:00 2001 From: mguessan Date: Fri, 6 Aug 2010 23:50:55 +0000 Subject: [PATCH] SMTP: compare actual email address, not email with alias git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1329 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ExchangeSession.java | 4 ++-- src/test/davmail/smtp/TestSmtp.java | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) 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());