File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -747,7 +747,7 @@ class MimePart {
747
747
748
748
MimeAttachment att;
749
749
att.type = type;
750
- if (att.type == " application/octet-stream " && filename.length == 0 && name.length > 0 ) {
750
+ if (filename.length == 0 && name.length > 0 ) {
751
751
att.filename = name;
752
752
} else {
753
753
att.filename = filename;
@@ -1218,11 +1218,17 @@ class IncomingEmailMessage : EmailMessage {
1218
1218
break ;
1219
1219
case " multipart/mixed" :
1220
1220
if (part.stuff.length) {
1221
- auto msg = part.stuff[0 ];
1222
- foreach (thing; part.stuff[1 .. $]) {
1223
- attachments ~= thing.toMimeAttachment();
1221
+ MimePart msg;
1222
+ foreach (idx, thing; part.stuff) {
1223
+ if (msg is null && thing.disposition != " attachment" && (thing.type.length == 0 || thing.type.indexOf(" multipart/" ) != - 1 || thing.type.indexOf(" text/" ) != - 1 )) {
1224
+ // the message should be the first suitable item for conversion
1225
+ msg = thing;
1226
+ } else {
1227
+ attachments ~= thing.toMimeAttachment();
1228
+ }
1224
1229
}
1225
- part = msg;
1230
+ if (msg)
1231
+ part = msg;
1226
1232
goto deeperInTheMimeTree;
1227
1233
}
1228
1234
@@ -1653,7 +1659,7 @@ unittest {
1653
1659
1654
1660
assert (result.subject.equal(mail.subject));
1655
1661
assert (mail.to.canFind(result.to));
1656
- assert (result.from == mail.from.toString );
1662
+ assert (result.from == mail.from.toProtocolString );
1657
1663
1658
1664
// This roundtrip works modulo trailing newline on the parsed message and LF vs CRLF
1659
1665
assert (result.textMessageBody.replace(" \n " , " \r\n " ).stripRight().equal(mail.textBody_));
You can’t perform that action at this time.
0 commit comments