mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -05:00
SMTP: try to force IMS encoding mode according to message contenttype
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1430 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
4ed0ae43aa
commit
a72a43741a
@ -2079,6 +2079,9 @@ public class DavExchangeSession extends ExchangeSession {
|
||||
// note: draft is readonly after create, create the message first with requested messageFlags
|
||||
davProperties.add(Field.createDavProperty("messageFlags", properties.get("draft")));
|
||||
}
|
||||
if (properties != null && properties.containsKey("mailOverrideFormat")) {
|
||||
davProperties.add(Field.createDavProperty("mailOverrideFormat", properties.get("mailOverrideFormat")));
|
||||
}
|
||||
if (!davProperties.isEmpty()) {
|
||||
patchMethod = new PropPatchMethod(messageUrl, davProperties);
|
||||
try {
|
||||
@ -2195,12 +2198,22 @@ public class DavExchangeSession extends ExchangeSession {
|
||||
|
||||
@Override
|
||||
public void sendMessage(MimeMessage mimeMessage) throws IOException {
|
||||
try {
|
||||
// need to create draft first
|
||||
String itemName = UUID.randomUUID().toString() + ".EML";
|
||||
HashMap<String, String> properties = new HashMap<String, String>();
|
||||
properties.put("draft", "9");
|
||||
String contentType = mimeMessage.getContentType();
|
||||
if (contentType != null && contentType.startsWith("text/plain")) {
|
||||
properties.put("mailOverrideFormat", "2");
|
||||
} else {
|
||||
properties.put("mailOverrideFormat", "1");
|
||||
}
|
||||
createMessage(DRAFTS, itemName, properties, mimeMessage);
|
||||
moveItem(DRAFTS + '/' + itemName, SENDMSG);
|
||||
} catch (MessagingException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isGzipEncoded(HttpMethod method) {
|
||||
|
@ -215,6 +215,24 @@ public class TestSmtp extends AbstractDavMailTestCase {
|
||||
sendAndCheckMessage(mimeMessage);
|
||||
}
|
||||
|
||||
public void testSendPlainTextMessage() throws IOException, MessagingException, InterruptedException {
|
||||
String body = "Test plain text message";
|
||||
MimeMessage mimeMessage = new MimeMessage((Session) null);
|
||||
mimeMessage.addHeader("To", Settings.getProperty("davmail.to"));
|
||||
mimeMessage.setSubject("Test text/plain message");
|
||||
mimeMessage.setText(body);
|
||||
sendAndCheckMessage(mimeMessage);
|
||||
}
|
||||
|
||||
public void testSendHtmlMessage() throws IOException, MessagingException, InterruptedException {
|
||||
String body = "Test html message <font color=\"#ff0000\">red</font>";
|
||||
MimeMessage mimeMessage = new MimeMessage((Session) null);
|
||||
mimeMessage.addHeader("To", Settings.getProperty("davmail.to"));
|
||||
mimeMessage.setSubject("Test html message");
|
||||
mimeMessage.setContent(body, "text/html");
|
||||
sendAndCheckMessage(mimeMessage);
|
||||
}
|
||||
|
||||
public void testQuit() throws IOException {
|
||||
writeLine("QUIT");
|
||||
assertEquals("221 Closing connection", readLine());
|
||||
|
Loading…
Reference in New Issue
Block a user