mirror of
https://github.com/moparisthebest/davmail
synced 2024-08-13 16:53:51 -04:00
SMTP: rewrite getAllRecipients to disable strict header check
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1473 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
82a6cd0e3f
commit
fe73982491
@ -35,7 +35,6 @@ import org.htmlcleaner.CommentToken;
|
|||||||
import org.htmlcleaner.HtmlCleaner;
|
import org.htmlcleaner.HtmlCleaner;
|
||||||
import org.htmlcleaner.TagNode;
|
import org.htmlcleaner.TagNode;
|
||||||
|
|
||||||
import javax.mail.Address;
|
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
@ -633,6 +632,11 @@ public abstract class ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
public abstract MessageList searchMessages(String folderName, Set<String> attributes, Condition condition) throws IOException;
|
public abstract MessageList searchMessages(String folderName, Set<String> attributes, Condition condition) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get server version (Exchange2003, Exchange2007 or Exchange2010)
|
||||||
|
*
|
||||||
|
* @return server version
|
||||||
|
*/
|
||||||
public String getServerVersion() {
|
public String getServerVersion() {
|
||||||
return serverVersion;
|
return serverVersion;
|
||||||
}
|
}
|
||||||
@ -1074,11 +1078,9 @@ public abstract class ExchangeSession {
|
|||||||
|
|
||||||
// remove visible recipients from list
|
// remove visible recipients from list
|
||||||
Set<String> visibleRecipients = new HashSet<String>();
|
Set<String> visibleRecipients = new HashSet<String>();
|
||||||
Address[] recipients = mimeMessage.getAllRecipients();
|
List<InternetAddress> recipients = getAllRecipients(mimeMessage);
|
||||||
if (recipients != null) {
|
for (InternetAddress address : recipients) {
|
||||||
for (Address address : recipients) {
|
visibleRecipients.add((address.getAddress().toLowerCase()));
|
||||||
visibleRecipients.add(((InternetAddress) address).getAddress().toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (String recipient : rcptToRecipients) {
|
for (String recipient : rcptToRecipients) {
|
||||||
if (!visibleRecipients.contains(recipient.toLowerCase())) {
|
if (!visibleRecipients.contains(recipient.toLowerCase())) {
|
||||||
@ -1089,6 +1091,21 @@ public abstract class ExchangeSession {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final String[] RECIPIENT_HEADERS = {"to", "cc", "bcc"};
|
||||||
|
|
||||||
|
protected List<InternetAddress> getAllRecipients(MimeMessage mimeMessage) throws MessagingException {
|
||||||
|
List<InternetAddress> recipientList = new ArrayList<InternetAddress>();
|
||||||
|
for (String recipientHeader : RECIPIENT_HEADERS) {
|
||||||
|
final String recipientHeaderValue = mimeMessage.getHeader(recipientHeader, ",");
|
||||||
|
if (recipientHeaderValue != null) {
|
||||||
|
// parse headers in non strict mode
|
||||||
|
recipientList.addAll(Arrays.asList(InternetAddress.parseHeader(recipientHeaderValue, false)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return recipientList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send Mime message.
|
* Send Mime message.
|
||||||
*
|
*
|
||||||
@ -1208,6 +1225,7 @@ public abstract class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Move item from source path to target path.
|
* Move item from source path to target path.
|
||||||
|
*
|
||||||
* @param sourcePath item source path
|
* @param sourcePath item source path
|
||||||
* @param targetPath item target path
|
* @param targetPath item target path
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
|
Loading…
Reference in New Issue
Block a user