mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32:22 -05:00
SMTP: convert Resent- headers, see 3019708
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1364 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
a51d910df6
commit
5fca57f0f3
@ -95,6 +95,7 @@ public abstract class ExchangeSession {
|
|||||||
protected static final String INBOX = "INBOX";
|
protected static final String INBOX = "INBOX";
|
||||||
protected static final String LOWER_CASE_INBOX = "inbox";
|
protected static final String LOWER_CASE_INBOX = "inbox";
|
||||||
protected static final String SENT = "Sent";
|
protected static final String SENT = "Sent";
|
||||||
|
protected static final String SENDMSG = "##DavMailSubmissionURI##";
|
||||||
protected static final String DRAFTS = "Drafts";
|
protected static final String DRAFTS = "Drafts";
|
||||||
protected static final String TRASH = "Trash";
|
protected static final String TRASH = "Trash";
|
||||||
protected static final String JUNK = "Junk";
|
protected static final String JUNK = "Junk";
|
||||||
@ -1016,6 +1017,17 @@ public abstract class ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void convertResentHeader(MimeMessage mimeMessage, String headerName) throws MessagingException {
|
||||||
|
String[] resentHeader = mimeMessage.getHeader("Resent-"+headerName);
|
||||||
|
if (resentHeader != null) {
|
||||||
|
mimeMessage.removeHeader("Resent-"+headerName);
|
||||||
|
mimeMessage.removeHeader(headerName);
|
||||||
|
for (String value:resentHeader) {
|
||||||
|
mimeMessage.addHeader(headerName, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send message in reader to recipients.
|
* Send message in reader to recipients.
|
||||||
* Detect visible recipients in message body to determine bcc recipients
|
* Detect visible recipients in message body to determine bcc recipients
|
||||||
@ -1031,6 +1043,12 @@ public abstract class ExchangeSession {
|
|||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
LOGGER.debug("Dropping message id " + mimeMessage.getMessageID() + ": already sent");
|
LOGGER.debug("Dropping message id " + mimeMessage.getMessageID() + ": already sent");
|
||||||
} else {
|
} else {
|
||||||
|
convertResentHeader(mimeMessage, "From");
|
||||||
|
convertResentHeader(mimeMessage, "To");
|
||||||
|
convertResentHeader(mimeMessage, "Cc");
|
||||||
|
convertResentHeader(mimeMessage, "Bcc");
|
||||||
|
convertResentHeader(mimeMessage, "Message-Id");
|
||||||
|
|
||||||
// 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();
|
Address[] recipients = mimeMessage.getAllRecipients();
|
||||||
|
@ -95,6 +95,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
protected String inboxName;
|
protected String inboxName;
|
||||||
protected String deleteditemsName;
|
protected String deleteditemsName;
|
||||||
protected String sentitemsName;
|
protected String sentitemsName;
|
||||||
|
protected String sendmsgName;
|
||||||
protected String draftsName;
|
protected String draftsName;
|
||||||
protected String calendarName;
|
protected String calendarName;
|
||||||
protected String contactsName;
|
protected String contactsName;
|
||||||
@ -119,6 +120,8 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
exchangeFolderPath = mailPath + draftsName + folderPath.substring(DRAFTS.length());
|
exchangeFolderPath = mailPath + draftsName + folderPath.substring(DRAFTS.length());
|
||||||
} else if (folderPath.startsWith(SENT)) {
|
} else if (folderPath.startsWith(SENT)) {
|
||||||
exchangeFolderPath = mailPath + sentitemsName + folderPath.substring(SENT.length());
|
exchangeFolderPath = mailPath + sentitemsName + folderPath.substring(SENT.length());
|
||||||
|
} else if (folderPath.startsWith(SENDMSG)) {
|
||||||
|
exchangeFolderPath = mailPath + sendmsgName + folderPath.substring(SENDMSG.length());
|
||||||
} else if (folderPath.startsWith(CONTACTS)) {
|
} else if (folderPath.startsWith(CONTACTS)) {
|
||||||
exchangeFolderPath = mailPath + contactsName + folderPath.substring(CONTACTS.length());
|
exchangeFolderPath = mailPath + contactsName + folderPath.substring(CONTACTS.length());
|
||||||
} else if (folderPath.startsWith(CALENDAR)) {
|
} else if (folderPath.startsWith(CALENDAR)) {
|
||||||
@ -600,7 +603,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
protected String getFolderName(String url) {
|
protected String getFolderName(String url) {
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
if (url.endsWith("/")) {
|
if (url.endsWith("/")) {
|
||||||
return url.substring(url.lastIndexOf('/', url.length() - 2) + 1);
|
return url.substring(url.lastIndexOf('/', url.length() - 2) + 1, url.length()-1);
|
||||||
} else if (url.indexOf('/') > 0) {
|
} else if (url.indexOf('/') > 0) {
|
||||||
return url.substring(url.lastIndexOf('/') + 1);
|
return url.substring(url.lastIndexOf('/') + 1);
|
||||||
} else {
|
} else {
|
||||||
@ -628,6 +631,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
sentitemsUrl = getURIPropertyIfExists(properties, "sentitems");
|
sentitemsUrl = getURIPropertyIfExists(properties, "sentitems");
|
||||||
sentitemsName = getFolderName(sentitemsUrl);
|
sentitemsName = getFolderName(sentitemsUrl);
|
||||||
sendmsgUrl = getURIPropertyIfExists(properties, "sendmsg");
|
sendmsgUrl = getURIPropertyIfExists(properties, "sendmsg");
|
||||||
|
sendmsgName = getFolderName(sendmsgUrl);
|
||||||
draftsUrl = getURIPropertyIfExists(properties, "drafts");
|
draftsUrl = getURIPropertyIfExists(properties, "drafts");
|
||||||
draftsName = getFolderName(draftsUrl);
|
draftsName = getFolderName(draftsUrl);
|
||||||
calendarUrl = getURIPropertyIfExists(properties, "calendar");
|
calendarUrl = getURIPropertyIfExists(properties, "calendar");
|
||||||
@ -2043,7 +2047,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
public void sendMessage(byte[] messageBody) throws IOException {
|
public void sendMessage(byte[] messageBody) throws IOException {
|
||||||
String messageName = UUID.randomUUID().toString() + ".EML";
|
String messageName = UUID.randomUUID().toString() + ".EML";
|
||||||
|
|
||||||
createMessage(sendmsgUrl, messageName, null, messageBody);
|
createMessage(SENDMSG, messageName, null, messageBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isGzipEncoded(HttpMethod method) {
|
protected boolean isGzipEncoded(HttpMethod method) {
|
||||||
|
Loading…
Reference in New Issue
Block a user