1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 03:32:22 -05:00

SMTP: fix 3024482, avoid duplicate messages with gmail

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1228 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-20 14:09:40 +00:00
parent 70b368a66b
commit 7064d5a690
2 changed files with 36 additions and 19 deletions

View File

@ -194,6 +194,7 @@ public abstract class ExchangeSession {
/**
* Return standard zulu date formatter.
*
* @return zulu date formatter
*/
public static SimpleDateFormat getZuluDateFormat() {
@ -917,6 +918,11 @@ public abstract class ExchangeSession {
* @throws MessagingException on error
*/
public void sendMessage(List<String> rcptToRecipients, MimeMessage mimeMessage) throws IOException, MessagingException {
// check Sent folder for duplicates
ExchangeSession.MessageList messages = searchMessages(SENT, headerEquals("message-id", mimeMessage.getMessageID()));
if (!messages.isEmpty()) {
LOGGER.debug("Dropping message: already sent");
} else {
// Exchange 2007 : skip From: header
mimeMessage.removeHeader("from");
@ -936,6 +942,7 @@ public abstract class ExchangeSession {
sendMessage(baos.toByteArray());
}
}
/**
* Get folder object.

View File

@ -148,6 +148,16 @@ public class TestSmtp extends AbstractDavMailTestCase {
sendAndCheckMessage(mimeMessage);
}
public void testSendMessageTwice() throws IOException, MessagingException, InterruptedException {
String body = "First line\r\n.\r\nSecond line";
MimeMessage mimeMessage = new MimeMessage((Session) null);
mimeMessage.addHeader("to", Settings.getProperty("davmail.to"));
mimeMessage.setSubject("Test subject");
mimeMessage.setText(body);
sendAndCheckMessage(mimeMessage);
sendAndCheckMessage(mimeMessage);
}
public void testQuit() throws IOException {
writeLine("QUIT");
assertEquals("221 Closing connection", readLine());