1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 11:12:22 -05:00

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
This commit is contained in:
mguessan 2010-08-06 23:50:55 +00:00
parent bd12bbd30e
commit 889673e3e3
2 changed files with 11 additions and 2 deletions

View File

@ -959,10 +959,10 @@ public abstract class ExchangeSession {
Set<String> visibleRecipients = new HashSet<String>(); Set<String> visibleRecipients = new HashSet<String>();
Address[] recipients = mimeMessage.getAllRecipients(); Address[] recipients = mimeMessage.getAllRecipients();
for (Address address : recipients) { for (Address address : recipients) {
visibleRecipients.add(address.toString()); visibleRecipients.add(((InternetAddress)address).getAddress().toLowerCase());
} }
for (String recipient : rcptToRecipients) { for (String recipient : rcptToRecipients) {
if (!visibleRecipients.contains(recipient)) { if (!visibleRecipients.contains(recipient.toLowerCase())) {
mimeMessage.addRecipient(javax.mail.Message.RecipientType.BCC, new InternetAddress(recipient)); mimeMessage.addRecipient(javax.mail.Message.RecipientType.BCC, new InternetAddress(recipient));
} }
} }

View File

@ -173,6 +173,15 @@ public class TestSmtp extends AbstractDavMailTestCase {
sendAndCheckMessage(mimeMessage); 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 { public void testQuit() throws IOException {
writeLine("QUIT"); writeLine("QUIT");
assertEquals("221 Closing connection", readLine()); assertEquals("221 Closing connection", readLine());