From 8e5381f60b7df59096e0772a95fe22907b446458 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Mon, 4 Sep 2023 15:23:45 +0200 Subject: [PATCH] Project reorganization --- Cargo.toml | 2 +- benches/libraries.rs | 121 - examples/mailbox_iterate_maildir.rs | 13 +- resources/address.json | 678 +++ {tests => resources/eml}/legacy/000.crlf.json | 0 {tests => resources/eml}/legacy/000.eml | 0 {tests => resources/eml}/legacy/000.json | 0 {tests => resources/eml}/legacy/001.crlf.json | 0 {tests => resources/eml}/legacy/001.eml | 0 {tests => resources/eml}/legacy/001.json | 0 {tests => resources/eml}/legacy/002.crlf.json | 0 {tests => resources/eml}/legacy/002.eml | 0 {tests => resources/eml}/legacy/002.json | 0 {tests => resources/eml}/legacy/003.crlf.json | 0 {tests => resources/eml}/legacy/003.eml | 0 {tests => resources/eml}/legacy/003.json | 0 {tests => resources/eml}/legacy/004.crlf.json | 0 {tests => resources/eml}/legacy/004.eml | 0 {tests => resources/eml}/legacy/004.json | 0 {tests => resources/eml}/legacy/005.crlf.json | 0 {tests => resources/eml}/legacy/005.eml | 0 {tests => resources/eml}/legacy/005.json | 0 {tests => resources/eml}/legacy/006.crlf.json | 0 {tests => resources/eml}/legacy/006.eml | 0 {tests => resources/eml}/legacy/006.json | 0 {tests => resources/eml}/legacy/007.crlf.json | 0 {tests => resources/eml}/legacy/007.eml | 0 {tests => resources/eml}/legacy/007.json | 0 {tests => resources/eml}/legacy/008.crlf.json | 0 {tests => resources/eml}/legacy/008.eml | 0 {tests => resources/eml}/legacy/008.json | 0 {tests => resources/eml}/legacy/009.crlf.json | 0 {tests => resources/eml}/legacy/009.eml | 0 {tests => resources/eml}/legacy/009.json | 0 {tests => resources/eml}/legacy/010.crlf.json | 0 {tests => resources/eml}/legacy/010.eml | 0 {tests => resources/eml}/legacy/010.json | 0 {tests => resources/eml}/legacy/011.crlf.json | 0 {tests => resources/eml}/legacy/011.eml | 0 {tests => resources/eml}/legacy/011.json | 0 {tests => resources/eml}/legacy/012.crlf.json | 0 {tests => resources/eml}/legacy/012.eml | 0 {tests => resources/eml}/legacy/012.json | 0 {tests => resources/eml}/legacy/013.crlf.json | 0 {tests => resources/eml}/legacy/013.eml | 0 {tests => resources/eml}/legacy/013.json | 0 {tests => resources/eml}/legacy/014.crlf.json | 0 {tests => resources/eml}/legacy/014.eml | 0 {tests => resources/eml}/legacy/014.json | 0 {tests => resources/eml}/legacy/015.crlf.json | 0 {tests => resources/eml}/legacy/015.eml | 0 {tests => resources/eml}/legacy/015.json | 0 {tests => resources/eml}/legacy/016.crlf.json | 0 {tests => resources/eml}/legacy/016.eml | 0 {tests => resources/eml}/legacy/016.json | 0 {tests => resources/eml}/legacy/017.crlf.json | 0 {tests => resources/eml}/legacy/017.eml | 0 {tests => resources/eml}/legacy/017.json | 0 {tests => resources/eml}/legacy/018.crlf.json | 0 {tests => resources/eml}/legacy/018.eml | 0 {tests => resources/eml}/legacy/018.json | 0 {tests => resources/eml}/legacy/019.crlf.json | 0 {tests => resources/eml}/legacy/019.eml | 0 {tests => resources/eml}/legacy/019.json | 0 {tests => resources/eml}/legacy/020.crlf.json | 0 {tests => resources/eml}/legacy/020.eml | 0 {tests => resources/eml}/legacy/020.json | 0 {tests => resources/eml}/legacy/021.crlf.json | 0 {tests => resources/eml}/legacy/021.eml | 0 {tests => resources/eml}/legacy/021.json | 0 {tests => resources/eml}/legacy/022.crlf.json | 0 {tests => resources/eml}/legacy/022.eml | 0 {tests => resources/eml}/legacy/022.json | 0 {tests => resources/eml}/legacy/023.crlf.json | 0 {tests => resources/eml}/legacy/023.eml | 0 {tests => resources/eml}/legacy/023.json | 0 {tests => resources/eml}/legacy/024.crlf.json | 0 {tests => resources/eml}/legacy/024.eml | 0 {tests => resources/eml}/legacy/024.json | 0 {tests => resources/eml}/legacy/025.crlf.json | 0 {tests => resources/eml}/legacy/025.eml | 0 {tests => resources/eml}/legacy/025.json | 0 {tests => resources/eml}/legacy/026.crlf.json | 0 {tests => resources/eml}/legacy/026.eml | 0 {tests => resources/eml}/legacy/026.json | 0 {tests => resources/eml}/legacy/027.crlf.json | 0 {tests => resources/eml}/legacy/027.eml | 0 {tests => resources/eml}/legacy/027.json | 0 {tests => resources/eml}/legacy/028.crlf.json | 0 {tests => resources/eml}/legacy/028.eml | 0 {tests => resources/eml}/legacy/028.json | 0 {tests => resources/eml}/legacy/029.crlf.json | 0 {tests => resources/eml}/legacy/029.eml | 0 {tests => resources/eml}/legacy/029.json | 0 {tests => resources/eml}/legacy/030.crlf.json | 0 {tests => resources/eml}/legacy/030.eml | 0 {tests => resources/eml}/legacy/030.json | 0 {tests => resources/eml}/legacy/031.crlf.json | 0 {tests => resources/eml}/legacy/031.eml | 0 {tests => resources/eml}/legacy/031.json | 0 {tests => resources/eml}/legacy/032.crlf.json | 0 {tests => resources/eml}/legacy/032.eml | 0 {tests => resources/eml}/legacy/032.json | 0 {tests => resources/eml}/legacy/033.crlf.json | 0 {tests => resources/eml}/legacy/033.eml | 0 {tests => resources/eml}/legacy/033.json | 0 {tests => resources/eml}/legacy/034.crlf.json | 0 {tests => resources/eml}/legacy/034.eml | 0 {tests => resources/eml}/legacy/034.json | 0 {tests => resources/eml}/legacy/035.crlf.json | 0 {tests => resources/eml}/legacy/035.eml | 0 {tests => resources/eml}/legacy/035.json | 0 {tests => resources/eml}/legacy/036.crlf.json | 0 {tests => resources/eml}/legacy/036.eml | 0 {tests => resources/eml}/legacy/036.json | 0 {tests => resources/eml}/legacy/037.crlf.json | 0 {tests => resources/eml}/legacy/037.eml | 0 {tests => resources/eml}/legacy/037.json | 0 {tests => resources/eml}/legacy/038.crlf.json | 0 {tests => resources/eml}/legacy/038.eml | 0 {tests => resources/eml}/legacy/038.json | 0 {tests => resources/eml}/legacy/039.crlf.json | 0 {tests => resources/eml}/legacy/039.eml | 0 {tests => resources/eml}/legacy/039.json | 0 {tests => resources/eml}/legacy/040.crlf.json | 0 {tests => resources/eml}/legacy/040.eml | 0 {tests => resources/eml}/legacy/040.json | 0 {tests => resources/eml}/legacy/041.crlf.json | 0 {tests => resources/eml}/legacy/041.eml | 0 {tests => resources/eml}/legacy/041.json | 0 {tests => resources/eml}/legacy/042.crlf.json | 0 {tests => resources/eml}/legacy/042.eml | 0 {tests => resources/eml}/legacy/042.json | 0 {tests => resources/eml}/legacy/043.crlf.json | 0 {tests => resources/eml}/legacy/043.eml | 0 {tests => resources/eml}/legacy/043.json | 0 {tests => resources/eml}/legacy/044.crlf.json | 0 {tests => resources/eml}/legacy/044.eml | 0 {tests => resources/eml}/legacy/044.json | 0 {tests => resources/eml}/legacy/045.crlf.json | 0 {tests => resources/eml}/legacy/045.eml | 0 {tests => resources/eml}/legacy/045.json | 0 {tests => resources/eml}/legacy/046.crlf.json | 0 {tests => resources/eml}/legacy/046.eml | 0 {tests => resources/eml}/legacy/046.json | 0 {tests => resources/eml}/legacy/047.crlf.json | 0 {tests => resources/eml}/legacy/047.eml | 0 {tests => resources/eml}/legacy/047.json | 0 {tests => resources/eml}/legacy/048.crlf.json | 0 {tests => resources/eml}/legacy/048.eml | 0 {tests => resources/eml}/legacy/048.json | 0 {tests => resources/eml}/legacy/049.crlf.json | 0 {tests => resources/eml}/legacy/049.eml | 0 {tests => resources/eml}/legacy/049.json | 0 {tests => resources/eml}/legacy/050.crlf.json | 0 {tests => resources/eml}/legacy/050.eml | 0 {tests => resources/eml}/legacy/050.json | 0 {tests => resources/eml}/legacy/051.crlf.json | 0 {tests => resources/eml}/legacy/051.eml | 0 {tests => resources/eml}/legacy/051.json | 0 {tests => resources/eml}/legacy/052.crlf.json | 0 {tests => resources/eml}/legacy/052.eml | 0 {tests => resources/eml}/legacy/052.json | 0 {tests => resources/eml}/legacy/053.crlf.json | 0 {tests => resources/eml}/legacy/053.eml | 0 {tests => resources/eml}/legacy/053.json | 0 {tests => resources/eml}/legacy/COPYING | 0 .../eml}/malformed/000.crlf.json | 0 {tests => resources/eml}/malformed/000.eml | 0 {tests => resources/eml}/malformed/000.json | 0 .../eml}/malformed/001.crlf.json | 0 {tests => resources/eml}/malformed/001.eml | 0 {tests => resources/eml}/malformed/001.json | 0 .../eml}/malformed/002.crlf.json | 0 {tests => resources/eml}/malformed/002.eml | 0 {tests => resources/eml}/malformed/002.json | 0 .../eml}/malformed/003.crlf.json | 0 {tests => resources/eml}/malformed/003.eml | 0 {tests => resources/eml}/malformed/003.json | 0 .../eml}/malformed/004.crlf.json | 0 {tests => resources/eml}/malformed/004.eml | 0 {tests => resources/eml}/malformed/004.json | 0 .../eml}/malformed/005.crlf.json | 0 {tests => resources/eml}/malformed/005.eml | 0 {tests => resources/eml}/malformed/005.json | 0 .../eml}/malformed/006.crlf.json | 0 {tests => resources/eml}/malformed/006.eml | 0 {tests => resources/eml}/malformed/006.json | 0 .../eml}/malformed/007.crlf.json | 0 {tests => resources/eml}/malformed/007.eml | 0 {tests => resources/eml}/malformed/007.json | 0 .../eml}/malformed/008.crlf.json | 0 {tests => resources/eml}/malformed/008.eml | 0 {tests => resources/eml}/malformed/008.json | 0 .../eml}/malformed/009.crlf.json | 0 {tests => resources/eml}/malformed/009.eml | 0 {tests => resources/eml}/malformed/009.json | 0 .../eml}/malformed/010.crlf.json | 0 {tests => resources/eml}/malformed/010.eml | 0 {tests => resources/eml}/malformed/010.json | 0 .../eml}/malformed/011.crlf.json | 0 {tests => resources/eml}/malformed/011.eml | 0 {tests => resources/eml}/malformed/011.json | 0 .../eml}/malformed/012.crlf.json | 0 {tests => resources/eml}/malformed/012.eml | 0 {tests => resources/eml}/malformed/012.json | 0 .../eml}/malformed/013.crlf.json | 0 {tests => resources/eml}/malformed/013.eml | 0 {tests => resources/eml}/malformed/013.json | 0 .../eml}/malformed/014.crlf.json | 0 {tests => resources/eml}/malformed/014.eml | 0 {tests => resources/eml}/malformed/014.json | 0 .../eml}/malformed/015.crlf.json | 0 {tests => resources/eml}/malformed/015.eml | 0 {tests => resources/eml}/malformed/015.json | 0 .../eml}/malformed/016.crlf.json | 0 {tests => resources/eml}/malformed/016.eml | 0 {tests => resources/eml}/malformed/016.json | 0 {tests => resources/eml}/malformed/COPYING | 0 {tests => resources/eml}/rfc/000.crlf.json | 0 {tests => resources/eml}/rfc/000.eml | 0 {tests => resources/eml}/rfc/000.json | 0 {tests => resources/eml}/rfc/001.crlf.json | 0 {tests => resources/eml}/rfc/001.eml | 0 {tests => resources/eml}/rfc/001.json | 0 {tests => resources/eml}/rfc/002.crlf.json | 0 {tests => resources/eml}/rfc/002.eml | 0 {tests => resources/eml}/rfc/002.json | 0 {tests => resources/eml}/rfc/003.crlf.json | 0 {tests => resources/eml}/rfc/003.eml | 0 {tests => resources/eml}/rfc/003.json | 0 {tests => resources/eml}/rfc/004.crlf.json | 0 {tests => resources/eml}/rfc/004.eml | 0 {tests => resources/eml}/rfc/004.json | 0 {tests => resources/eml}/rfc/005.crlf.json | 0 {tests => resources/eml}/rfc/005.eml | 0 {tests => resources/eml}/rfc/005.json | 0 {tests => resources/eml}/rfc/006.crlf.json | 0 {tests => resources/eml}/rfc/006.eml | 0 {tests => resources/eml}/rfc/006.json | 0 {tests => resources/eml}/rfc/007.crlf.json | 0 {tests => resources/eml}/rfc/007.eml | 0 {tests => resources/eml}/rfc/007.json | 0 {tests => resources/eml}/rfc/008.crlf.json | 0 {tests => resources/eml}/rfc/008.eml | 0 {tests => resources/eml}/rfc/008.json | 0 {tests => resources/eml}/rfc/009.crlf.json | 0 {tests => resources/eml}/rfc/009.eml | 0 {tests => resources/eml}/rfc/009.json | 0 .../eml}/thirdparty/000.crlf.json | 0 {tests => resources/eml}/thirdparty/000.eml | 0 {tests => resources/eml}/thirdparty/000.json | 0 .../eml}/thirdparty/001.crlf.json | 0 {tests => resources/eml}/thirdparty/001.eml | 0 {tests => resources/eml}/thirdparty/001.json | 0 .../eml}/thirdparty/002.crlf.json | 0 {tests => resources/eml}/thirdparty/002.eml | 0 {tests => resources/eml}/thirdparty/002.json | 0 .../eml}/thirdparty/003.crlf.json | 0 {tests => resources/eml}/thirdparty/003.eml | 0 {tests => resources/eml}/thirdparty/003.json | 0 .../eml}/thirdparty/004.crlf.json | 0 {tests => resources/eml}/thirdparty/004.eml | 0 {tests => resources/eml}/thirdparty/004.json | 0 .../eml}/thirdparty/005.crlf.json | 0 {tests => resources/eml}/thirdparty/005.eml | Bin {tests => resources/eml}/thirdparty/005.json | 0 .../eml}/thirdparty/006.crlf.json | 0 {tests => resources/eml}/thirdparty/006.eml | 0 {tests => resources/eml}/thirdparty/006.json | 0 .../eml}/thirdparty/007.crlf.json | 0 {tests => resources/eml}/thirdparty/007.eml | 0 {tests => resources/eml}/thirdparty/007.json | 0 .../eml}/thirdparty/008.crlf.json | 0 {tests => resources/eml}/thirdparty/008.eml | 0 {tests => resources/eml}/thirdparty/008.json | 0 .../eml}/thirdparty/009.crlf.json | 0 {tests => resources/eml}/thirdparty/009.eml | 0 {tests => resources/eml}/thirdparty/009.json | 0 .../eml}/thirdparty/010.crlf.json | 0 {tests => resources/eml}/thirdparty/010.eml | 0 {tests => resources/eml}/thirdparty/010.json | 0 .../eml}/thirdparty/011.crlf.json | 0 {tests => resources/eml}/thirdparty/011.eml | 0 {tests => resources/eml}/thirdparty/011.json | 0 .../eml}/thirdparty/012.crlf.json | 0 {tests => resources/eml}/thirdparty/012.eml | 0 {tests => resources/eml}/thirdparty/012.json | 0 .../eml}/thirdparty/013.crlf.json | 0 {tests => resources/eml}/thirdparty/013.eml | 0 {tests => resources/eml}/thirdparty/013.json | 0 {tests => resources/eml}/thirdparty/COPYING | 0 .../cur/1276533073.M242911P3632.kurkku;2,FP | 0 ...339.27041_118.foo.org,S=1000,W=1030;2,RDF, | 0 ...8339.27041_118.foo.org,S=1000,W=1030;2,TDR | 0 ...28487.M364837P9451.kurkku,S=1355,W=1394;2, | 0 ...004F3030E_0.mx1.example.com,S=10956;2,STln | 0 ....M20046P2137.mailserver,S=4542,W=4642;2,Sb | 0 resources/received.json | 4204 +++++++++++++++++ src/core/address.rs | 44 + src/core/body.rs | 58 + src/core/header.rs | 747 +++ src/core/message.rs | 489 ++ src/core/mod.rs | 15 + src/lib.rs | 1372 +----- src/mailbox/maildir.rs | 13 +- src/parsers/fields/address.rs | 8 +- src/parsers/fields/mod.rs | 57 + src/parsers/fields/received.rs | 227 +- src/parsers/message.rs | 7 +- 310 files changed, 6521 insertions(+), 1534 deletions(-) delete mode 100644 benches/libraries.rs create mode 100644 resources/address.json rename {tests => resources/eml}/legacy/000.crlf.json (100%) rename {tests => resources/eml}/legacy/000.eml (100%) rename {tests => resources/eml}/legacy/000.json (100%) rename {tests => resources/eml}/legacy/001.crlf.json (100%) rename {tests => resources/eml}/legacy/001.eml (100%) rename {tests => resources/eml}/legacy/001.json (100%) rename {tests => resources/eml}/legacy/002.crlf.json (100%) rename {tests => resources/eml}/legacy/002.eml (100%) rename {tests => resources/eml}/legacy/002.json (100%) rename {tests => resources/eml}/legacy/003.crlf.json (100%) rename {tests => resources/eml}/legacy/003.eml (100%) rename {tests => resources/eml}/legacy/003.json (100%) rename {tests => resources/eml}/legacy/004.crlf.json (100%) rename {tests => resources/eml}/legacy/004.eml (100%) rename {tests => resources/eml}/legacy/004.json (100%) rename {tests => resources/eml}/legacy/005.crlf.json (100%) rename {tests => resources/eml}/legacy/005.eml (100%) rename {tests => resources/eml}/legacy/005.json (100%) rename {tests => resources/eml}/legacy/006.crlf.json (100%) rename {tests => resources/eml}/legacy/006.eml (100%) rename {tests => resources/eml}/legacy/006.json (100%) rename {tests => resources/eml}/legacy/007.crlf.json (100%) rename {tests => resources/eml}/legacy/007.eml (100%) rename {tests => resources/eml}/legacy/007.json (100%) rename {tests => resources/eml}/legacy/008.crlf.json (100%) rename {tests => resources/eml}/legacy/008.eml (100%) rename {tests => resources/eml}/legacy/008.json (100%) rename {tests => resources/eml}/legacy/009.crlf.json (100%) rename {tests => resources/eml}/legacy/009.eml (100%) rename {tests => resources/eml}/legacy/009.json (100%) rename {tests => resources/eml}/legacy/010.crlf.json (100%) rename {tests => resources/eml}/legacy/010.eml (100%) rename {tests => resources/eml}/legacy/010.json (100%) rename {tests => resources/eml}/legacy/011.crlf.json (100%) rename {tests => resources/eml}/legacy/011.eml (100%) rename {tests => resources/eml}/legacy/011.json (100%) rename {tests => resources/eml}/legacy/012.crlf.json (100%) rename {tests => resources/eml}/legacy/012.eml (100%) rename {tests => resources/eml}/legacy/012.json (100%) rename {tests => resources/eml}/legacy/013.crlf.json (100%) rename {tests => resources/eml}/legacy/013.eml (100%) rename {tests => resources/eml}/legacy/013.json (100%) rename {tests => resources/eml}/legacy/014.crlf.json (100%) rename {tests => resources/eml}/legacy/014.eml (100%) rename {tests => resources/eml}/legacy/014.json (100%) rename {tests => resources/eml}/legacy/015.crlf.json (100%) rename {tests => resources/eml}/legacy/015.eml (100%) rename {tests => resources/eml}/legacy/015.json (100%) rename {tests => resources/eml}/legacy/016.crlf.json (100%) rename {tests => resources/eml}/legacy/016.eml (100%) rename {tests => resources/eml}/legacy/016.json (100%) rename {tests => resources/eml}/legacy/017.crlf.json (100%) rename {tests => resources/eml}/legacy/017.eml (100%) rename {tests => resources/eml}/legacy/017.json (100%) rename {tests => resources/eml}/legacy/018.crlf.json (100%) rename {tests => resources/eml}/legacy/018.eml (100%) rename {tests => resources/eml}/legacy/018.json (100%) rename {tests => resources/eml}/legacy/019.crlf.json (100%) rename {tests => resources/eml}/legacy/019.eml (100%) rename {tests => resources/eml}/legacy/019.json (100%) rename {tests => resources/eml}/legacy/020.crlf.json (100%) rename {tests => resources/eml}/legacy/020.eml (100%) rename {tests => resources/eml}/legacy/020.json (100%) rename {tests => resources/eml}/legacy/021.crlf.json (100%) rename {tests => resources/eml}/legacy/021.eml (100%) rename {tests => resources/eml}/legacy/021.json (100%) rename {tests => resources/eml}/legacy/022.crlf.json (100%) rename {tests => resources/eml}/legacy/022.eml (100%) rename {tests => resources/eml}/legacy/022.json (100%) rename {tests => resources/eml}/legacy/023.crlf.json (100%) rename {tests => resources/eml}/legacy/023.eml (100%) rename {tests => resources/eml}/legacy/023.json (100%) rename {tests => resources/eml}/legacy/024.crlf.json (100%) rename {tests => resources/eml}/legacy/024.eml (100%) rename {tests => resources/eml}/legacy/024.json (100%) rename {tests => resources/eml}/legacy/025.crlf.json (100%) rename {tests => resources/eml}/legacy/025.eml (100%) rename {tests => resources/eml}/legacy/025.json (100%) rename {tests => resources/eml}/legacy/026.crlf.json (100%) rename {tests => resources/eml}/legacy/026.eml (100%) rename {tests => resources/eml}/legacy/026.json (100%) rename {tests => resources/eml}/legacy/027.crlf.json (100%) rename {tests => resources/eml}/legacy/027.eml (100%) rename {tests => resources/eml}/legacy/027.json (100%) rename {tests => resources/eml}/legacy/028.crlf.json (100%) rename {tests => resources/eml}/legacy/028.eml (100%) rename {tests => resources/eml}/legacy/028.json (100%) rename {tests => resources/eml}/legacy/029.crlf.json (100%) rename {tests => resources/eml}/legacy/029.eml (100%) rename {tests => resources/eml}/legacy/029.json (100%) rename {tests => resources/eml}/legacy/030.crlf.json (100%) rename {tests => resources/eml}/legacy/030.eml (100%) rename {tests => resources/eml}/legacy/030.json (100%) rename {tests => resources/eml}/legacy/031.crlf.json (100%) rename {tests => resources/eml}/legacy/031.eml (100%) rename {tests => resources/eml}/legacy/031.json (100%) rename {tests => resources/eml}/legacy/032.crlf.json (100%) rename {tests => resources/eml}/legacy/032.eml (100%) rename {tests => resources/eml}/legacy/032.json (100%) rename {tests => resources/eml}/legacy/033.crlf.json (100%) rename {tests => resources/eml}/legacy/033.eml (100%) rename {tests => resources/eml}/legacy/033.json (100%) rename {tests => resources/eml}/legacy/034.crlf.json (100%) rename {tests => resources/eml}/legacy/034.eml (100%) rename {tests => resources/eml}/legacy/034.json (100%) rename {tests => resources/eml}/legacy/035.crlf.json (100%) rename {tests => resources/eml}/legacy/035.eml (100%) rename {tests => resources/eml}/legacy/035.json (100%) rename {tests => resources/eml}/legacy/036.crlf.json (100%) rename {tests => resources/eml}/legacy/036.eml (100%) rename {tests => resources/eml}/legacy/036.json (100%) rename {tests => resources/eml}/legacy/037.crlf.json (100%) rename {tests => resources/eml}/legacy/037.eml (100%) rename {tests => resources/eml}/legacy/037.json (100%) rename {tests => resources/eml}/legacy/038.crlf.json (100%) rename {tests => resources/eml}/legacy/038.eml (100%) rename {tests => resources/eml}/legacy/038.json (100%) rename {tests => resources/eml}/legacy/039.crlf.json (100%) rename {tests => resources/eml}/legacy/039.eml (100%) rename {tests => resources/eml}/legacy/039.json (100%) rename {tests => resources/eml}/legacy/040.crlf.json (100%) rename {tests => resources/eml}/legacy/040.eml (100%) rename {tests => resources/eml}/legacy/040.json (100%) rename {tests => resources/eml}/legacy/041.crlf.json (100%) rename {tests => resources/eml}/legacy/041.eml (100%) rename {tests => resources/eml}/legacy/041.json (100%) rename {tests => resources/eml}/legacy/042.crlf.json (100%) rename {tests => resources/eml}/legacy/042.eml (100%) rename {tests => resources/eml}/legacy/042.json (100%) rename {tests => resources/eml}/legacy/043.crlf.json (100%) rename {tests => resources/eml}/legacy/043.eml (100%) rename {tests => resources/eml}/legacy/043.json (100%) rename {tests => resources/eml}/legacy/044.crlf.json (100%) rename {tests => resources/eml}/legacy/044.eml (100%) rename {tests => resources/eml}/legacy/044.json (100%) rename {tests => resources/eml}/legacy/045.crlf.json (100%) rename {tests => resources/eml}/legacy/045.eml (100%) rename {tests => resources/eml}/legacy/045.json (100%) rename {tests => resources/eml}/legacy/046.crlf.json (100%) rename {tests => resources/eml}/legacy/046.eml (100%) rename {tests => resources/eml}/legacy/046.json (100%) rename {tests => resources/eml}/legacy/047.crlf.json (100%) rename {tests => resources/eml}/legacy/047.eml (100%) rename {tests => resources/eml}/legacy/047.json (100%) rename {tests => resources/eml}/legacy/048.crlf.json (100%) rename {tests => resources/eml}/legacy/048.eml (100%) rename {tests => resources/eml}/legacy/048.json (100%) rename {tests => resources/eml}/legacy/049.crlf.json (100%) rename {tests => resources/eml}/legacy/049.eml (100%) rename {tests => resources/eml}/legacy/049.json (100%) rename {tests => resources/eml}/legacy/050.crlf.json (100%) rename {tests => resources/eml}/legacy/050.eml (100%) rename {tests => resources/eml}/legacy/050.json (100%) rename {tests => resources/eml}/legacy/051.crlf.json (100%) rename {tests => resources/eml}/legacy/051.eml (100%) rename {tests => resources/eml}/legacy/051.json (100%) rename {tests => resources/eml}/legacy/052.crlf.json (100%) rename {tests => resources/eml}/legacy/052.eml (100%) rename {tests => resources/eml}/legacy/052.json (100%) rename {tests => resources/eml}/legacy/053.crlf.json (100%) rename {tests => resources/eml}/legacy/053.eml (100%) rename {tests => resources/eml}/legacy/053.json (100%) rename {tests => resources/eml}/legacy/COPYING (100%) rename {tests => resources/eml}/malformed/000.crlf.json (100%) rename {tests => resources/eml}/malformed/000.eml (100%) rename {tests => resources/eml}/malformed/000.json (100%) rename {tests => resources/eml}/malformed/001.crlf.json (100%) rename {tests => resources/eml}/malformed/001.eml (100%) rename {tests => resources/eml}/malformed/001.json (100%) rename {tests => resources/eml}/malformed/002.crlf.json (100%) rename {tests => resources/eml}/malformed/002.eml (100%) rename {tests => resources/eml}/malformed/002.json (100%) rename {tests => resources/eml}/malformed/003.crlf.json (100%) rename {tests => resources/eml}/malformed/003.eml (100%) rename {tests => resources/eml}/malformed/003.json (100%) rename {tests => resources/eml}/malformed/004.crlf.json (100%) rename {tests => resources/eml}/malformed/004.eml (100%) rename {tests => resources/eml}/malformed/004.json (100%) rename {tests => resources/eml}/malformed/005.crlf.json (100%) rename {tests => resources/eml}/malformed/005.eml (100%) rename {tests => resources/eml}/malformed/005.json (100%) rename {tests => resources/eml}/malformed/006.crlf.json (100%) rename {tests => resources/eml}/malformed/006.eml (100%) rename {tests => resources/eml}/malformed/006.json (100%) rename {tests => resources/eml}/malformed/007.crlf.json (100%) rename {tests => resources/eml}/malformed/007.eml (100%) rename {tests => resources/eml}/malformed/007.json (100%) rename {tests => resources/eml}/malformed/008.crlf.json (100%) rename {tests => resources/eml}/malformed/008.eml (100%) rename {tests => resources/eml}/malformed/008.json (100%) rename {tests => resources/eml}/malformed/009.crlf.json (100%) rename {tests => resources/eml}/malformed/009.eml (100%) rename {tests => resources/eml}/malformed/009.json (100%) rename {tests => resources/eml}/malformed/010.crlf.json (100%) rename {tests => resources/eml}/malformed/010.eml (100%) rename {tests => resources/eml}/malformed/010.json (100%) rename {tests => resources/eml}/malformed/011.crlf.json (100%) rename {tests => resources/eml}/malformed/011.eml (100%) rename {tests => resources/eml}/malformed/011.json (100%) rename {tests => resources/eml}/malformed/012.crlf.json (100%) rename {tests => resources/eml}/malformed/012.eml (100%) rename {tests => resources/eml}/malformed/012.json (100%) rename {tests => resources/eml}/malformed/013.crlf.json (100%) rename {tests => resources/eml}/malformed/013.eml (100%) rename {tests => resources/eml}/malformed/013.json (100%) rename {tests => resources/eml}/malformed/014.crlf.json (100%) rename {tests => resources/eml}/malformed/014.eml (100%) rename {tests => resources/eml}/malformed/014.json (100%) rename {tests => resources/eml}/malformed/015.crlf.json (100%) rename {tests => resources/eml}/malformed/015.eml (100%) rename {tests => resources/eml}/malformed/015.json (100%) rename {tests => resources/eml}/malformed/016.crlf.json (100%) rename {tests => resources/eml}/malformed/016.eml (100%) rename {tests => resources/eml}/malformed/016.json (100%) rename {tests => resources/eml}/malformed/COPYING (100%) rename {tests => resources/eml}/rfc/000.crlf.json (100%) rename {tests => resources/eml}/rfc/000.eml (100%) rename {tests => resources/eml}/rfc/000.json (100%) rename {tests => resources/eml}/rfc/001.crlf.json (100%) rename {tests => resources/eml}/rfc/001.eml (100%) rename {tests => resources/eml}/rfc/001.json (100%) rename {tests => resources/eml}/rfc/002.crlf.json (100%) rename {tests => resources/eml}/rfc/002.eml (100%) rename {tests => resources/eml}/rfc/002.json (100%) rename {tests => resources/eml}/rfc/003.crlf.json (100%) rename {tests => resources/eml}/rfc/003.eml (100%) rename {tests => resources/eml}/rfc/003.json (100%) rename {tests => resources/eml}/rfc/004.crlf.json (100%) rename {tests => resources/eml}/rfc/004.eml (100%) rename {tests => resources/eml}/rfc/004.json (100%) rename {tests => resources/eml}/rfc/005.crlf.json (100%) rename {tests => resources/eml}/rfc/005.eml (100%) rename {tests => resources/eml}/rfc/005.json (100%) rename {tests => resources/eml}/rfc/006.crlf.json (100%) rename {tests => resources/eml}/rfc/006.eml (100%) rename {tests => resources/eml}/rfc/006.json (100%) rename {tests => resources/eml}/rfc/007.crlf.json (100%) rename {tests => resources/eml}/rfc/007.eml (100%) rename {tests => resources/eml}/rfc/007.json (100%) rename {tests => resources/eml}/rfc/008.crlf.json (100%) rename {tests => resources/eml}/rfc/008.eml (100%) rename {tests => resources/eml}/rfc/008.json (100%) rename {tests => resources/eml}/rfc/009.crlf.json (100%) rename {tests => resources/eml}/rfc/009.eml (100%) rename {tests => resources/eml}/rfc/009.json (100%) rename {tests => resources/eml}/thirdparty/000.crlf.json (100%) rename {tests => resources/eml}/thirdparty/000.eml (100%) rename {tests => resources/eml}/thirdparty/000.json (100%) rename {tests => resources/eml}/thirdparty/001.crlf.json (100%) rename {tests => resources/eml}/thirdparty/001.eml (100%) rename {tests => resources/eml}/thirdparty/001.json (100%) rename {tests => resources/eml}/thirdparty/002.crlf.json (100%) rename {tests => resources/eml}/thirdparty/002.eml (100%) rename {tests => resources/eml}/thirdparty/002.json (100%) rename {tests => resources/eml}/thirdparty/003.crlf.json (100%) rename {tests => resources/eml}/thirdparty/003.eml (100%) rename {tests => resources/eml}/thirdparty/003.json (100%) rename {tests => resources/eml}/thirdparty/004.crlf.json (100%) rename {tests => resources/eml}/thirdparty/004.eml (100%) rename {tests => resources/eml}/thirdparty/004.json (100%) rename {tests => resources/eml}/thirdparty/005.crlf.json (100%) rename {tests => resources/eml}/thirdparty/005.eml (100%) rename {tests => resources/eml}/thirdparty/005.json (100%) rename {tests => resources/eml}/thirdparty/006.crlf.json (100%) rename {tests => resources/eml}/thirdparty/006.eml (100%) rename {tests => resources/eml}/thirdparty/006.json (100%) rename {tests => resources/eml}/thirdparty/007.crlf.json (100%) rename {tests => resources/eml}/thirdparty/007.eml (100%) rename {tests => resources/eml}/thirdparty/007.json (100%) rename {tests => resources/eml}/thirdparty/008.crlf.json (100%) rename {tests => resources/eml}/thirdparty/008.eml (100%) rename {tests => resources/eml}/thirdparty/008.json (100%) rename {tests => resources/eml}/thirdparty/009.crlf.json (100%) rename {tests => resources/eml}/thirdparty/009.eml (100%) rename {tests => resources/eml}/thirdparty/009.json (100%) rename {tests => resources/eml}/thirdparty/010.crlf.json (100%) rename {tests => resources/eml}/thirdparty/010.eml (100%) rename {tests => resources/eml}/thirdparty/010.json (100%) rename {tests => resources/eml}/thirdparty/011.crlf.json (100%) rename {tests => resources/eml}/thirdparty/011.eml (100%) rename {tests => resources/eml}/thirdparty/011.json (100%) rename {tests => resources/eml}/thirdparty/012.crlf.json (100%) rename {tests => resources/eml}/thirdparty/012.eml (100%) rename {tests => resources/eml}/thirdparty/012.json (100%) rename {tests => resources/eml}/thirdparty/013.crlf.json (100%) rename {tests => resources/eml}/thirdparty/013.eml (100%) rename {tests => resources/eml}/thirdparty/013.json (100%) rename {tests => resources/eml}/thirdparty/COPYING (100%) rename {tests => resources}/maildir/.My Folder.Nested Folder/cur/1276533073.M242911P3632.kurkku;2,FP (100%) rename {tests => resources}/maildir/.My Folder.Nested Folder/new/1035478339.27041_118.foo.org,S=1000,W=1030;2,RDF, (100%) rename {tests => resources}/maildir/.My Folder/cur/1035478339.27041_118.foo.org,S=1000,W=1030;2,TDR (100%) rename {tests => resources}/maildir/.My Folder/new/1276528487.M364837P9451.kurkku,S=1355,W=1394;2, (100%) rename {tests => resources}/maildir/cur/1491941793.M41850P8566V0000000000000015I0000000004F3030E_0.mx1.example.com,S=10956;2,STln (100%) rename {tests => resources}/maildir/new/1234567890.M20046P2137.mailserver,S=4542,W=4642;2,Sb (100%) create mode 100644 resources/received.json create mode 100644 src/core/address.rs create mode 100644 src/core/body.rs create mode 100644 src/core/header.rs create mode 100644 src/core/message.rs create mode 100644 src/core/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 3d4ce28..01f5adb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mail-parser" description = "Fast and robust e-mail parsing library for Rust" -version = "0.8.2" +version = "0.9.0" edition = "2018" authors = [ "Stalwart Labs "] license = "Apache-2.0 OR MIT" diff --git a/benches/libraries.rs b/benches/libraries.rs deleted file mode 100644 index f3e9795..0000000 --- a/benches/libraries.rs +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright Stalwart Labs Ltd. See the COPYING - * file at the top-level directory of this distribution. - * - * Licensed under the Apache License, Version 2.0 or the MIT license - * , at your - * option. This file may not be copied, modified, or distributed - * except according to those terms. - */ - -#![feature(test)] - -extern crate test; - -use std::{fs, path::PathBuf}; - -use test::Bencher; - -fn bench_all_samples(b: &mut Bencher, name: &str, fnc: fn(&[u8], &str)) { - const SEPARATOR: &[u8] = "\n---- EXPECTED STRUCTURE ----\n".as_bytes(); - - println!("Benchmarking {}...\n", name); - let mut test_data = Vec::new(); - - for test_suite in ["rfc", "legacy", "thirdparty", "malformed"] { - let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - test_dir.push("tests"); - test_dir.push(test_suite); - - let mut bench_count = 0; - - for file_name in fs::read_dir(&test_dir).unwrap() { - let file_name = file_name.as_ref().unwrap().path(); - if file_name.extension().map_or(false, |e| e == "txt") { - let input = fs::read(&file_name).unwrap(); - let mut pos = 0; - - for sep_pos in 0..input.len() { - if input[sep_pos..sep_pos + SEPARATOR.len()].eq(SEPARATOR) { - pos = sep_pos; - break; - } - } - - assert!( - pos > 0, - "Failed to find separator in test file '{}'.", - file_name.display() - ); - - test_data.push(Vec::from(&input[0..pos])); - bench_count += 1; - } - } - - assert!( - bench_count > 0, - "Did not find any benchmarks to run in folder {}.", - test_dir.display() - ); - } - - b.iter(|| { - for test_msg in &test_data { - fnc(test_msg, String::from_utf8_lossy(&test_msg).as_ref()); - } - }); -} - -#[bench] -fn bench_stalwart(b: &mut Bencher) { - bench_all_samples(b, "stalwart_mail_parser", |bytes, _str| { - mail_parser::Message::parse(bytes); - }); -} - -// These libraries do not support all RFCs and might be faster -// on the benchmarks as they do not parse all header fields, -// do not decode encoded parts or fail while trying to parse the messages. -// Also no text body conversion between HTML/plain-text is done by these. -// -// To benchmark against these libraries, add to Cargo.toml dev-dependencies: -// -// email = "0.0.21" -// email-format = "0.8" -// email-parser = { version = "0.5.0", features=["headers", "mime"] } -// mailparse = "0.13" - -/* - -#[bench] -fn bench_email_parser(b: &mut Bencher) { - bench_all_samples(b, "email_parser", |bytes, _str| { - email_parser::prelude::parse_message(bytes).unwrap(); - }); -} - -#[bench] -fn bench_mailparse(b: &mut Bencher) { - bench_all_samples(b, "mailparse", |bytes, _str| { - mailparse::parse_mail(bytes).unwrap(); - }); -} - -#[bench] -fn benchmark_email(b: &mut Bencher) { - bench_all_samples(b, "email", |_bytes, str| { - email::rfc5322::Rfc5322Parser::new(str).consume_message(); - }); -} - -#[bench] -fn bench_email_format(b: &mut Bencher) { - use email_format::rfc5322::Parsable; - bench_all_samples(b, "email_format", |bytes, _str| { - email_format::Email::parse(bytes).unwrap(); - }); -} - -*/ diff --git a/examples/mailbox_iterate_maildir.rs b/examples/mailbox_iterate_maildir.rs index ad3abb5..0d32edb 100644 --- a/examples/mailbox_iterate_maildir.rs +++ b/examples/mailbox_iterate_maildir.rs @@ -15,11 +15,14 @@ use mail_parser::mailbox::maildir::FolderIterator; fn main() { // Iterates a Maildir++ structure printing the results to stdout. - let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - test_dir.push("tests"); - test_dir.push("maildir"); - - for folder in FolderIterator::new(test_dir, ".".into()).unwrap() { + for folder in FolderIterator::new( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("resources") + .join("maildir"), + ".".into(), + ) + .unwrap() + { let folder = folder.unwrap(); println!("------\nMailbox: {:?}", folder.name().unwrap_or("INBOX")); diff --git a/resources/address.json b/resources/address.json new file mode 100644 index 0000000..1c5749c --- /dev/null +++ b/resources/address.json @@ -0,0 +1,678 @@ +[ + { + "header": "John Doe \n", + "expected": { + "Address": { + "name": "John Doe", + "address": "jdoe@machine.example" + } + } + }, + { + "header": " Mary Smith \n", + "expected": { + "Address": { + "name": "Mary Smith", + "address": "mary@example.net" + } + } + }, + { + "header": "\"Joe Q. Public\" \n", + "expected": { + "Address": { + "name": "Joe Q. Public", + "address": "john.q.public@example.com" + } + } + }, + { + "header": "Mary Smith , jdoe@example.org, Who? \n", + "expected": { + "AddressList": [ + { + "name": "Mary Smith", + "address": "mary@x.test" + }, + { + "name": null, + "address": "jdoe@example.org" + }, + { + "name": "Who?", + "address": "one@y.test" + } + ] + } + }, + { + "header": ", \"Giant; \\\"Big\\\" Box\" \n", + "expected": { + "AddressList": [ + { + "name": null, + "address": "boss@nil.test" + }, + { + "name": "Giant; \"Big\" Box", + "address": "sysservices@example.net" + } + ] + } + }, + { + "header": "A Group:Ed Jones ,joe@where.test,John ;\n", + "expected": { + "Group": { + "name": "A Group", + "addresses": [ + { + "name": "Ed Jones", + "address": "c@a.test" + }, + { + "name": null, + "address": "joe@where.test" + }, + { + "name": "John", + "address": "jdoe@one.test" + } + ] + } + } + }, + { + "header": "Undisclosed recipients:;\n", + "expected": { + "Group": { + "name": "Undisclosed recipients", + "addresses": [] + } + } + }, + { + "header": "\"Mary Smith: Personal Account\" \n", + "expected": { + "Address": { + "name": "Mary Smith: Personal Account", + "address": "smith@home.example" + } + } + }, + { + "header": "Pete(A nice \\) chap) \n", + "expected": { + "Address": { + "name": "Pete (A nice ) chap his account his host)", + "address": "pete@silly.test" + } + } + }, + { + "header": "Pete(A nice \n \\\n ) chap) \n", + "expected": { + "Address": { + "name": "Pete (A nice ) chap his account his host)", + "address": "pete@silly.test" + } + } + }, + { + "header": "A Group(Some people)\n :Chris Jones ,\n joe@example.org,\n John (my dear friend); (the end of the group)\n", + "expected": { + "GroupList": [ + { + "name": "A Group (Some people)", + "addresses": [ + { + "name": "Chris Jones (Chris's host.)", + "address": "c@public.example" + }, + { + "name": null, + "address": "joe@example.org" + }, + { + "name": "John (my dear friend)", + "address": "jdoe@one.test" + } + ] + }, + { + "name": null, + "addresses": [ + { + "name": "the end of the group", + "address": null + } + ] + } + ] + } + }, + { + "header": "(Empty list)(start)Hidden recipients :(nobody(that I know)) ;\n", + "expected": { + "Group": { + "name": "Hidden recipients (Empty list start)", + "addresses": [ + { + "name": "nobody(that I know)", + "address": null + } + ] + } + } + }, + { + "header": "Joe Q. Public \n", + "expected": { + "Address": { + "name": "Joe Q. Public", + "address": "john.q.public@example.com" + } + } + }, + { + "header": "Mary Smith <@node.test:mary@example.net>, , jdoe@test . example\n", + "expected": { + "AddressList": [ + { + "name": "Mary Smith", + "address": "@node.test:mary@example.net" + }, + { + "name": null, + "address": "jdoe@test . example" + } + ] + } + }, + { + "header": "John Doe \n", + "expected": { + "Address": { + "name": "John Doe (comment)", + "address": "jdoe@machine. example" + } + } + }, + { + "header": "Mary Smith\n \n\t\n", + "expected": { + "Address": { + "name": "Mary Smith", + "address": "mary@example.net" + } + } + }, + { + "header": "=?US-ASCII*EN?Q?Keith_Moore?= \n", + "expected": { + "Address": { + "name": "Keith Moore", + "address": "moore@cs.utk.edu" + } + } + }, + { + "header": "John =?US-ASCII*EN?Q?Doe?= \n", + "expected": { + "Address": { + "name": "John Doe", + "address": "moore@cs.utk.edu" + } + } + }, + { + "header": "=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= \n", + "expected": { + "Address": { + "name": "Keld Jørn Simonsen", + "address": "keld@dkuug.dk" + } + } + }, + { + "header": "=?ISO-8859-1?Q?Andr=E9?= Pirard \n", + "expected": { + "Address": { + "name": "André Pirard", + "address": "PIRARD@vm1.ulg.ac.be" + } + } + }, + { + "header": "=?ISO-8859-1?Q?Olle_J=E4rnefors?= \n", + "expected": { + "Address": { + "name": "Olle Järnefors", + "address": "ojarnef@admin.kth.se" + } + } + }, + { + "header": "ietf-822@dimacs.rutgers.edu, ojarnef@admin.kth.se\n", + "expected": { + "AddressList": [ + { + "name": null, + "address": "ietf-822@dimacs.rutgers.edu" + }, + { + "name": null, + "address": "ojarnef@admin.kth.se" + } + ] + } + }, + { + "header": "Nathaniel Borenstein \n (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=)\n", + "expected": { + "Address": { + "name": "Nathaniel Borenstein (םולש ןב ילטפנ)", + "address": "nsb@thumper.bellcore.com" + } + } + }, + { + "header": "Greg Vaudreuil , Ned Freed\n , Keith Moore \n", + "expected": { + "AddressList": [ + { + "name": "Greg Vaudreuil", + "address": "gvaudre@NRI.Reston.VA.US" + }, + { + "name": "Ned Freed", + "address": "ned@innosoft.com" + }, + { + "name": "Keith Moore", + "address": "moore@cs.utk.edu" + } + ] + } + }, + { + "header": "=?ISO-8859-1?Q?a?= \n", + "expected": { + "Address": { + "name": "a", + "address": "test@test.com" + } + } + }, + { + "header": "\"=?ISO-8859-1?Q?a?= b\" \n", + "expected": { + "Address": { + "name": "a b", + "address": "test@test.com" + } + } + }, + { + "header": "=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?= \n", + "expected": { + "Address": { + "name": "ab", + "address": "test@test.com" + } + } + }, + { + "header": "=?ISO-8859-1?Q?a?=\n =?ISO-8859-1?Q?b?= \n", + "expected": { + "Address": { + "name": "ab", + "address": "test@test.com" + } + } + }, + { + "header": "=?ISO-8859-1?Q?a?= \"=?ISO-8859-2?Q?_b?=\" \n", + "expected": { + "Address": { + "name": "a b", + "address": "test@test.com" + } + } + }, + { + "header": " \n", + "expected": { + "Address": { + "name": null, + "address": "test@test.com" + } + } + }, + { + "header": "test@test.com\ninvalid@address.com\n", + "expected": { + "Address": { + "name": null, + "address": "test@test.com" + } + } + }, + { + "header": "\"=?ISO-8859-1?Q =?ISO-8859-1?Q?a?= \\\" =?ISO-8859-1?Q?b?=\" \n\nbody@content.com", + "expected": { + "Address": { + "name": "=?ISO-8859-1?Q a \" b", + "address": "last@address.com" + } + } + }, + { + "header": "=? \n", + "expected": { + "Address": { + "name": "=?", + "address": "name@domain.com" + } + } + }, + { + "header": "\" James Smythe\" , Friends:\n jane@example.com, =?UTF-8?Q?John_Sm=C3=AEth?=\n ;\n", + "expected": { + "GroupList": [ + { + "name": null, + "addresses": [ + { + "name": " James Smythe", + "address": "james@example.com" + } + ] + }, + { + "name": "Friends", + "addresses": [ + { + "name": null, + "address": "jane@example.com" + }, + { + "name": "John Smîth", + "address": "john@example.com" + } + ] + } + ] + } + }, + { + "header": "List 1: addr1@test.com, addr2@test.com; List 2: addr3@test.com, addr4@test.com; addr5@test.com, addr6@test.com\n", + "expected": { + "GroupList": [ + { + "name": "List 1", + "addresses": [ + { + "name": null, + "address": "addr1@test.com" + }, + { + "name": null, + "address": "addr2@test.com" + } + ] + }, + { + "name": "List 2", + "addresses": [ + { + "name": null, + "address": "addr3@test.com" + }, + { + "name": null, + "address": "addr4@test.com" + } + ] + }, + { + "name": null, + "addresses": [ + { + "name": null, + "address": "addr5@test.com" + }, + { + "name": null, + "address": "addr6@test.com" + } + ] + } + ] + } + }, + { + "header": "\"List 1\": addr1@test.com, addr2@test.com; \"List 2\": addr3@test.com, addr4@test.com; addr5@test.com, addr6@test.com\n", + "expected": { + "GroupList": [ + { + "name": "List 1", + "addresses": [ + { + "name": null, + "address": "addr1@test.com" + }, + { + "name": null, + "address": "addr2@test.com" + } + ] + }, + { + "name": "List 2", + "addresses": [ + { + "name": null, + "address": "addr3@test.com" + }, + { + "name": null, + "address": "addr4@test.com" + } + ] + }, + { + "name": null, + "addresses": [ + { + "name": null, + "address": "addr5@test.com" + }, + { + "name": null, + "address": "addr6@test.com" + } + ] + } + ] + } + }, + { + "header": "\"=?utf-8?b?VGjDrXMgw61zIHbDoWzDrWQgw5pURjg=?=\": addr1@test.com, addr2@test.com; =?utf-8?b?VGjDrXMgw61zIHbDoWzDrWQgw5pURjg=?=: addr3@test.com, addr4@test.com; addr5@test.com, addr6@test.com\n", + "expected": { + "GroupList": [ + { + "name": "Thís ís válíd ÚTF8", + "addresses": [ + { + "name": null, + "address": "addr1@test.com" + }, + { + "name": null, + "address": "addr2@test.com" + } + ] + }, + { + "name": "Thís ís válíd ÚTF8", + "addresses": [ + { + "name": null, + "address": "addr3@test.com" + }, + { + "name": null, + "address": "addr4@test.com" + } + ] + }, + { + "name": null, + "addresses": [ + { + "name": null, + "address": "addr5@test.com" + }, + { + "name": null, + "address": "addr6@test.com" + } + ] + } + ] + } + }, + { + "header": " (Web Archive)\n", + "expected": { + "Address": { + "name": "Web Archive", + "address": "http://www.host.com/list/archive/" + } + } + }, + { + "header": "\n", + "expected": { + "Address": { + "name": null, + "address": "mailto:archive@host.com?subject=index%20list" + } + } + }, + { + "header": " (Postings are Moderated)\n", + "expected": { + "Address": { + "name": "Postings are Moderated", + "address": "mailto:moderator@host.com" + } + } + }, + { + "header": "(Use this command to join the list)\n \n", + "expected": { + "Address": { + "name": "Use this command to join the list", + "address": "mailto:list-manager@host.com?body=subscribe%20list" + } + } + }, + { + "header": ",\n \n", + "expected": { + "AddressList": [ + { + "name": null, + "address": "http://www.host.com/list.cgi?cmd=sub&lst=list" + }, + { + "name": null, + "address": "mailto:list-manager@host.com?body=subscribe%20list" + } + ] + } + }, + { + "header": "NO (posting not allowed on this list)\n", + "expected": { + "Address": { + "name": "posting not allowed on this list", + "address": "NO" + } + } + }, + { + "header": " (FTP),\n \n", + "expected": { + "AddressList": [ + { + "name": "FTP", + "address": "ftp://ftp.host.com/list.txt" + }, + { + "name": null, + "address": "mailto:list@host.com?subject=help" + } + ] + } + }, + { + "header": ", \n", + "expected": { + "AddressList": [ + { + "name": null, + "address": "http://www.host.com/list/" + }, + { + "name": null, + "address": "mailto:list-info@host.com" + } + ] + } + }, + { + "header": "(Use this command to get off the list)\n \n", + "expected": { + "Address": { + "name": "Use this command to get off the list", + "address": "mailto:list-manager@host.com?body=unsubscribe%20list" + } + } + }, + { + "header": ",\n \n", + "expected": { + "AddressList": [ + { + "name": null, + "address": "http://www.host.com/list.cgi?cmd=unsub&lst=list" + }, + { + "name": null, + "address": "mailto:list-request@host.com?subject=unsubscribe" + } + ] + } + }, + { + "header": " (Contact Person for Help)\n", + "expected": { + "Address": { + "name": "Contact Person for Help", + "address": "mailto:listmom@host.com" + } + } + }, + { + "header": "\"\\\\\\\\\\\\\\\\S. NIG\\\\\\\\\\\\\\\\\" ", + "expected": { + "Address": { + "name": "\\\\\\\\S. NIG\\\\\\\\", + "address": "first.last@host.com" + } + } + } +] \ No newline at end of file diff --git a/tests/legacy/000.crlf.json b/resources/eml/legacy/000.crlf.json similarity index 100% rename from tests/legacy/000.crlf.json rename to resources/eml/legacy/000.crlf.json diff --git a/tests/legacy/000.eml b/resources/eml/legacy/000.eml similarity index 100% rename from tests/legacy/000.eml rename to resources/eml/legacy/000.eml diff --git a/tests/legacy/000.json b/resources/eml/legacy/000.json similarity index 100% rename from tests/legacy/000.json rename to resources/eml/legacy/000.json diff --git a/tests/legacy/001.crlf.json b/resources/eml/legacy/001.crlf.json similarity index 100% rename from tests/legacy/001.crlf.json rename to resources/eml/legacy/001.crlf.json diff --git a/tests/legacy/001.eml b/resources/eml/legacy/001.eml similarity index 100% rename from tests/legacy/001.eml rename to resources/eml/legacy/001.eml diff --git a/tests/legacy/001.json b/resources/eml/legacy/001.json similarity index 100% rename from tests/legacy/001.json rename to resources/eml/legacy/001.json diff --git a/tests/legacy/002.crlf.json b/resources/eml/legacy/002.crlf.json similarity index 100% rename from tests/legacy/002.crlf.json rename to resources/eml/legacy/002.crlf.json diff --git a/tests/legacy/002.eml b/resources/eml/legacy/002.eml similarity index 100% rename from tests/legacy/002.eml rename to resources/eml/legacy/002.eml diff --git a/tests/legacy/002.json b/resources/eml/legacy/002.json similarity index 100% rename from tests/legacy/002.json rename to resources/eml/legacy/002.json diff --git a/tests/legacy/003.crlf.json b/resources/eml/legacy/003.crlf.json similarity index 100% rename from tests/legacy/003.crlf.json rename to resources/eml/legacy/003.crlf.json diff --git a/tests/legacy/003.eml b/resources/eml/legacy/003.eml similarity index 100% rename from tests/legacy/003.eml rename to resources/eml/legacy/003.eml diff --git a/tests/legacy/003.json b/resources/eml/legacy/003.json similarity index 100% rename from tests/legacy/003.json rename to resources/eml/legacy/003.json diff --git a/tests/legacy/004.crlf.json b/resources/eml/legacy/004.crlf.json similarity index 100% rename from tests/legacy/004.crlf.json rename to resources/eml/legacy/004.crlf.json diff --git a/tests/legacy/004.eml b/resources/eml/legacy/004.eml similarity index 100% rename from tests/legacy/004.eml rename to resources/eml/legacy/004.eml diff --git a/tests/legacy/004.json b/resources/eml/legacy/004.json similarity index 100% rename from tests/legacy/004.json rename to resources/eml/legacy/004.json diff --git a/tests/legacy/005.crlf.json b/resources/eml/legacy/005.crlf.json similarity index 100% rename from tests/legacy/005.crlf.json rename to resources/eml/legacy/005.crlf.json diff --git a/tests/legacy/005.eml b/resources/eml/legacy/005.eml similarity index 100% rename from tests/legacy/005.eml rename to resources/eml/legacy/005.eml diff --git a/tests/legacy/005.json b/resources/eml/legacy/005.json similarity index 100% rename from tests/legacy/005.json rename to resources/eml/legacy/005.json diff --git a/tests/legacy/006.crlf.json b/resources/eml/legacy/006.crlf.json similarity index 100% rename from tests/legacy/006.crlf.json rename to resources/eml/legacy/006.crlf.json diff --git a/tests/legacy/006.eml b/resources/eml/legacy/006.eml similarity index 100% rename from tests/legacy/006.eml rename to resources/eml/legacy/006.eml diff --git a/tests/legacy/006.json b/resources/eml/legacy/006.json similarity index 100% rename from tests/legacy/006.json rename to resources/eml/legacy/006.json diff --git a/tests/legacy/007.crlf.json b/resources/eml/legacy/007.crlf.json similarity index 100% rename from tests/legacy/007.crlf.json rename to resources/eml/legacy/007.crlf.json diff --git a/tests/legacy/007.eml b/resources/eml/legacy/007.eml similarity index 100% rename from tests/legacy/007.eml rename to resources/eml/legacy/007.eml diff --git a/tests/legacy/007.json b/resources/eml/legacy/007.json similarity index 100% rename from tests/legacy/007.json rename to resources/eml/legacy/007.json diff --git a/tests/legacy/008.crlf.json b/resources/eml/legacy/008.crlf.json similarity index 100% rename from tests/legacy/008.crlf.json rename to resources/eml/legacy/008.crlf.json diff --git a/tests/legacy/008.eml b/resources/eml/legacy/008.eml similarity index 100% rename from tests/legacy/008.eml rename to resources/eml/legacy/008.eml diff --git a/tests/legacy/008.json b/resources/eml/legacy/008.json similarity index 100% rename from tests/legacy/008.json rename to resources/eml/legacy/008.json diff --git a/tests/legacy/009.crlf.json b/resources/eml/legacy/009.crlf.json similarity index 100% rename from tests/legacy/009.crlf.json rename to resources/eml/legacy/009.crlf.json diff --git a/tests/legacy/009.eml b/resources/eml/legacy/009.eml similarity index 100% rename from tests/legacy/009.eml rename to resources/eml/legacy/009.eml diff --git a/tests/legacy/009.json b/resources/eml/legacy/009.json similarity index 100% rename from tests/legacy/009.json rename to resources/eml/legacy/009.json diff --git a/tests/legacy/010.crlf.json b/resources/eml/legacy/010.crlf.json similarity index 100% rename from tests/legacy/010.crlf.json rename to resources/eml/legacy/010.crlf.json diff --git a/tests/legacy/010.eml b/resources/eml/legacy/010.eml similarity index 100% rename from tests/legacy/010.eml rename to resources/eml/legacy/010.eml diff --git a/tests/legacy/010.json b/resources/eml/legacy/010.json similarity index 100% rename from tests/legacy/010.json rename to resources/eml/legacy/010.json diff --git a/tests/legacy/011.crlf.json b/resources/eml/legacy/011.crlf.json similarity index 100% rename from tests/legacy/011.crlf.json rename to resources/eml/legacy/011.crlf.json diff --git a/tests/legacy/011.eml b/resources/eml/legacy/011.eml similarity index 100% rename from tests/legacy/011.eml rename to resources/eml/legacy/011.eml diff --git a/tests/legacy/011.json b/resources/eml/legacy/011.json similarity index 100% rename from tests/legacy/011.json rename to resources/eml/legacy/011.json diff --git a/tests/legacy/012.crlf.json b/resources/eml/legacy/012.crlf.json similarity index 100% rename from tests/legacy/012.crlf.json rename to resources/eml/legacy/012.crlf.json diff --git a/tests/legacy/012.eml b/resources/eml/legacy/012.eml similarity index 100% rename from tests/legacy/012.eml rename to resources/eml/legacy/012.eml diff --git a/tests/legacy/012.json b/resources/eml/legacy/012.json similarity index 100% rename from tests/legacy/012.json rename to resources/eml/legacy/012.json diff --git a/tests/legacy/013.crlf.json b/resources/eml/legacy/013.crlf.json similarity index 100% rename from tests/legacy/013.crlf.json rename to resources/eml/legacy/013.crlf.json diff --git a/tests/legacy/013.eml b/resources/eml/legacy/013.eml similarity index 100% rename from tests/legacy/013.eml rename to resources/eml/legacy/013.eml diff --git a/tests/legacy/013.json b/resources/eml/legacy/013.json similarity index 100% rename from tests/legacy/013.json rename to resources/eml/legacy/013.json diff --git a/tests/legacy/014.crlf.json b/resources/eml/legacy/014.crlf.json similarity index 100% rename from tests/legacy/014.crlf.json rename to resources/eml/legacy/014.crlf.json diff --git a/tests/legacy/014.eml b/resources/eml/legacy/014.eml similarity index 100% rename from tests/legacy/014.eml rename to resources/eml/legacy/014.eml diff --git a/tests/legacy/014.json b/resources/eml/legacy/014.json similarity index 100% rename from tests/legacy/014.json rename to resources/eml/legacy/014.json diff --git a/tests/legacy/015.crlf.json b/resources/eml/legacy/015.crlf.json similarity index 100% rename from tests/legacy/015.crlf.json rename to resources/eml/legacy/015.crlf.json diff --git a/tests/legacy/015.eml b/resources/eml/legacy/015.eml similarity index 100% rename from tests/legacy/015.eml rename to resources/eml/legacy/015.eml diff --git a/tests/legacy/015.json b/resources/eml/legacy/015.json similarity index 100% rename from tests/legacy/015.json rename to resources/eml/legacy/015.json diff --git a/tests/legacy/016.crlf.json b/resources/eml/legacy/016.crlf.json similarity index 100% rename from tests/legacy/016.crlf.json rename to resources/eml/legacy/016.crlf.json diff --git a/tests/legacy/016.eml b/resources/eml/legacy/016.eml similarity index 100% rename from tests/legacy/016.eml rename to resources/eml/legacy/016.eml diff --git a/tests/legacy/016.json b/resources/eml/legacy/016.json similarity index 100% rename from tests/legacy/016.json rename to resources/eml/legacy/016.json diff --git a/tests/legacy/017.crlf.json b/resources/eml/legacy/017.crlf.json similarity index 100% rename from tests/legacy/017.crlf.json rename to resources/eml/legacy/017.crlf.json diff --git a/tests/legacy/017.eml b/resources/eml/legacy/017.eml similarity index 100% rename from tests/legacy/017.eml rename to resources/eml/legacy/017.eml diff --git a/tests/legacy/017.json b/resources/eml/legacy/017.json similarity index 100% rename from tests/legacy/017.json rename to resources/eml/legacy/017.json diff --git a/tests/legacy/018.crlf.json b/resources/eml/legacy/018.crlf.json similarity index 100% rename from tests/legacy/018.crlf.json rename to resources/eml/legacy/018.crlf.json diff --git a/tests/legacy/018.eml b/resources/eml/legacy/018.eml similarity index 100% rename from tests/legacy/018.eml rename to resources/eml/legacy/018.eml diff --git a/tests/legacy/018.json b/resources/eml/legacy/018.json similarity index 100% rename from tests/legacy/018.json rename to resources/eml/legacy/018.json diff --git a/tests/legacy/019.crlf.json b/resources/eml/legacy/019.crlf.json similarity index 100% rename from tests/legacy/019.crlf.json rename to resources/eml/legacy/019.crlf.json diff --git a/tests/legacy/019.eml b/resources/eml/legacy/019.eml similarity index 100% rename from tests/legacy/019.eml rename to resources/eml/legacy/019.eml diff --git a/tests/legacy/019.json b/resources/eml/legacy/019.json similarity index 100% rename from tests/legacy/019.json rename to resources/eml/legacy/019.json diff --git a/tests/legacy/020.crlf.json b/resources/eml/legacy/020.crlf.json similarity index 100% rename from tests/legacy/020.crlf.json rename to resources/eml/legacy/020.crlf.json diff --git a/tests/legacy/020.eml b/resources/eml/legacy/020.eml similarity index 100% rename from tests/legacy/020.eml rename to resources/eml/legacy/020.eml diff --git a/tests/legacy/020.json b/resources/eml/legacy/020.json similarity index 100% rename from tests/legacy/020.json rename to resources/eml/legacy/020.json diff --git a/tests/legacy/021.crlf.json b/resources/eml/legacy/021.crlf.json similarity index 100% rename from tests/legacy/021.crlf.json rename to resources/eml/legacy/021.crlf.json diff --git a/tests/legacy/021.eml b/resources/eml/legacy/021.eml similarity index 100% rename from tests/legacy/021.eml rename to resources/eml/legacy/021.eml diff --git a/tests/legacy/021.json b/resources/eml/legacy/021.json similarity index 100% rename from tests/legacy/021.json rename to resources/eml/legacy/021.json diff --git a/tests/legacy/022.crlf.json b/resources/eml/legacy/022.crlf.json similarity index 100% rename from tests/legacy/022.crlf.json rename to resources/eml/legacy/022.crlf.json diff --git a/tests/legacy/022.eml b/resources/eml/legacy/022.eml similarity index 100% rename from tests/legacy/022.eml rename to resources/eml/legacy/022.eml diff --git a/tests/legacy/022.json b/resources/eml/legacy/022.json similarity index 100% rename from tests/legacy/022.json rename to resources/eml/legacy/022.json diff --git a/tests/legacy/023.crlf.json b/resources/eml/legacy/023.crlf.json similarity index 100% rename from tests/legacy/023.crlf.json rename to resources/eml/legacy/023.crlf.json diff --git a/tests/legacy/023.eml b/resources/eml/legacy/023.eml similarity index 100% rename from tests/legacy/023.eml rename to resources/eml/legacy/023.eml diff --git a/tests/legacy/023.json b/resources/eml/legacy/023.json similarity index 100% rename from tests/legacy/023.json rename to resources/eml/legacy/023.json diff --git a/tests/legacy/024.crlf.json b/resources/eml/legacy/024.crlf.json similarity index 100% rename from tests/legacy/024.crlf.json rename to resources/eml/legacy/024.crlf.json diff --git a/tests/legacy/024.eml b/resources/eml/legacy/024.eml similarity index 100% rename from tests/legacy/024.eml rename to resources/eml/legacy/024.eml diff --git a/tests/legacy/024.json b/resources/eml/legacy/024.json similarity index 100% rename from tests/legacy/024.json rename to resources/eml/legacy/024.json diff --git a/tests/legacy/025.crlf.json b/resources/eml/legacy/025.crlf.json similarity index 100% rename from tests/legacy/025.crlf.json rename to resources/eml/legacy/025.crlf.json diff --git a/tests/legacy/025.eml b/resources/eml/legacy/025.eml similarity index 100% rename from tests/legacy/025.eml rename to resources/eml/legacy/025.eml diff --git a/tests/legacy/025.json b/resources/eml/legacy/025.json similarity index 100% rename from tests/legacy/025.json rename to resources/eml/legacy/025.json diff --git a/tests/legacy/026.crlf.json b/resources/eml/legacy/026.crlf.json similarity index 100% rename from tests/legacy/026.crlf.json rename to resources/eml/legacy/026.crlf.json diff --git a/tests/legacy/026.eml b/resources/eml/legacy/026.eml similarity index 100% rename from tests/legacy/026.eml rename to resources/eml/legacy/026.eml diff --git a/tests/legacy/026.json b/resources/eml/legacy/026.json similarity index 100% rename from tests/legacy/026.json rename to resources/eml/legacy/026.json diff --git a/tests/legacy/027.crlf.json b/resources/eml/legacy/027.crlf.json similarity index 100% rename from tests/legacy/027.crlf.json rename to resources/eml/legacy/027.crlf.json diff --git a/tests/legacy/027.eml b/resources/eml/legacy/027.eml similarity index 100% rename from tests/legacy/027.eml rename to resources/eml/legacy/027.eml diff --git a/tests/legacy/027.json b/resources/eml/legacy/027.json similarity index 100% rename from tests/legacy/027.json rename to resources/eml/legacy/027.json diff --git a/tests/legacy/028.crlf.json b/resources/eml/legacy/028.crlf.json similarity index 100% rename from tests/legacy/028.crlf.json rename to resources/eml/legacy/028.crlf.json diff --git a/tests/legacy/028.eml b/resources/eml/legacy/028.eml similarity index 100% rename from tests/legacy/028.eml rename to resources/eml/legacy/028.eml diff --git a/tests/legacy/028.json b/resources/eml/legacy/028.json similarity index 100% rename from tests/legacy/028.json rename to resources/eml/legacy/028.json diff --git a/tests/legacy/029.crlf.json b/resources/eml/legacy/029.crlf.json similarity index 100% rename from tests/legacy/029.crlf.json rename to resources/eml/legacy/029.crlf.json diff --git a/tests/legacy/029.eml b/resources/eml/legacy/029.eml similarity index 100% rename from tests/legacy/029.eml rename to resources/eml/legacy/029.eml diff --git a/tests/legacy/029.json b/resources/eml/legacy/029.json similarity index 100% rename from tests/legacy/029.json rename to resources/eml/legacy/029.json diff --git a/tests/legacy/030.crlf.json b/resources/eml/legacy/030.crlf.json similarity index 100% rename from tests/legacy/030.crlf.json rename to resources/eml/legacy/030.crlf.json diff --git a/tests/legacy/030.eml b/resources/eml/legacy/030.eml similarity index 100% rename from tests/legacy/030.eml rename to resources/eml/legacy/030.eml diff --git a/tests/legacy/030.json b/resources/eml/legacy/030.json similarity index 100% rename from tests/legacy/030.json rename to resources/eml/legacy/030.json diff --git a/tests/legacy/031.crlf.json b/resources/eml/legacy/031.crlf.json similarity index 100% rename from tests/legacy/031.crlf.json rename to resources/eml/legacy/031.crlf.json diff --git a/tests/legacy/031.eml b/resources/eml/legacy/031.eml similarity index 100% rename from tests/legacy/031.eml rename to resources/eml/legacy/031.eml diff --git a/tests/legacy/031.json b/resources/eml/legacy/031.json similarity index 100% rename from tests/legacy/031.json rename to resources/eml/legacy/031.json diff --git a/tests/legacy/032.crlf.json b/resources/eml/legacy/032.crlf.json similarity index 100% rename from tests/legacy/032.crlf.json rename to resources/eml/legacy/032.crlf.json diff --git a/tests/legacy/032.eml b/resources/eml/legacy/032.eml similarity index 100% rename from tests/legacy/032.eml rename to resources/eml/legacy/032.eml diff --git a/tests/legacy/032.json b/resources/eml/legacy/032.json similarity index 100% rename from tests/legacy/032.json rename to resources/eml/legacy/032.json diff --git a/tests/legacy/033.crlf.json b/resources/eml/legacy/033.crlf.json similarity index 100% rename from tests/legacy/033.crlf.json rename to resources/eml/legacy/033.crlf.json diff --git a/tests/legacy/033.eml b/resources/eml/legacy/033.eml similarity index 100% rename from tests/legacy/033.eml rename to resources/eml/legacy/033.eml diff --git a/tests/legacy/033.json b/resources/eml/legacy/033.json similarity index 100% rename from tests/legacy/033.json rename to resources/eml/legacy/033.json diff --git a/tests/legacy/034.crlf.json b/resources/eml/legacy/034.crlf.json similarity index 100% rename from tests/legacy/034.crlf.json rename to resources/eml/legacy/034.crlf.json diff --git a/tests/legacy/034.eml b/resources/eml/legacy/034.eml similarity index 100% rename from tests/legacy/034.eml rename to resources/eml/legacy/034.eml diff --git a/tests/legacy/034.json b/resources/eml/legacy/034.json similarity index 100% rename from tests/legacy/034.json rename to resources/eml/legacy/034.json diff --git a/tests/legacy/035.crlf.json b/resources/eml/legacy/035.crlf.json similarity index 100% rename from tests/legacy/035.crlf.json rename to resources/eml/legacy/035.crlf.json diff --git a/tests/legacy/035.eml b/resources/eml/legacy/035.eml similarity index 100% rename from tests/legacy/035.eml rename to resources/eml/legacy/035.eml diff --git a/tests/legacy/035.json b/resources/eml/legacy/035.json similarity index 100% rename from tests/legacy/035.json rename to resources/eml/legacy/035.json diff --git a/tests/legacy/036.crlf.json b/resources/eml/legacy/036.crlf.json similarity index 100% rename from tests/legacy/036.crlf.json rename to resources/eml/legacy/036.crlf.json diff --git a/tests/legacy/036.eml b/resources/eml/legacy/036.eml similarity index 100% rename from tests/legacy/036.eml rename to resources/eml/legacy/036.eml diff --git a/tests/legacy/036.json b/resources/eml/legacy/036.json similarity index 100% rename from tests/legacy/036.json rename to resources/eml/legacy/036.json diff --git a/tests/legacy/037.crlf.json b/resources/eml/legacy/037.crlf.json similarity index 100% rename from tests/legacy/037.crlf.json rename to resources/eml/legacy/037.crlf.json diff --git a/tests/legacy/037.eml b/resources/eml/legacy/037.eml similarity index 100% rename from tests/legacy/037.eml rename to resources/eml/legacy/037.eml diff --git a/tests/legacy/037.json b/resources/eml/legacy/037.json similarity index 100% rename from tests/legacy/037.json rename to resources/eml/legacy/037.json diff --git a/tests/legacy/038.crlf.json b/resources/eml/legacy/038.crlf.json similarity index 100% rename from tests/legacy/038.crlf.json rename to resources/eml/legacy/038.crlf.json diff --git a/tests/legacy/038.eml b/resources/eml/legacy/038.eml similarity index 100% rename from tests/legacy/038.eml rename to resources/eml/legacy/038.eml diff --git a/tests/legacy/038.json b/resources/eml/legacy/038.json similarity index 100% rename from tests/legacy/038.json rename to resources/eml/legacy/038.json diff --git a/tests/legacy/039.crlf.json b/resources/eml/legacy/039.crlf.json similarity index 100% rename from tests/legacy/039.crlf.json rename to resources/eml/legacy/039.crlf.json diff --git a/tests/legacy/039.eml b/resources/eml/legacy/039.eml similarity index 100% rename from tests/legacy/039.eml rename to resources/eml/legacy/039.eml diff --git a/tests/legacy/039.json b/resources/eml/legacy/039.json similarity index 100% rename from tests/legacy/039.json rename to resources/eml/legacy/039.json diff --git a/tests/legacy/040.crlf.json b/resources/eml/legacy/040.crlf.json similarity index 100% rename from tests/legacy/040.crlf.json rename to resources/eml/legacy/040.crlf.json diff --git a/tests/legacy/040.eml b/resources/eml/legacy/040.eml similarity index 100% rename from tests/legacy/040.eml rename to resources/eml/legacy/040.eml diff --git a/tests/legacy/040.json b/resources/eml/legacy/040.json similarity index 100% rename from tests/legacy/040.json rename to resources/eml/legacy/040.json diff --git a/tests/legacy/041.crlf.json b/resources/eml/legacy/041.crlf.json similarity index 100% rename from tests/legacy/041.crlf.json rename to resources/eml/legacy/041.crlf.json diff --git a/tests/legacy/041.eml b/resources/eml/legacy/041.eml similarity index 100% rename from tests/legacy/041.eml rename to resources/eml/legacy/041.eml diff --git a/tests/legacy/041.json b/resources/eml/legacy/041.json similarity index 100% rename from tests/legacy/041.json rename to resources/eml/legacy/041.json diff --git a/tests/legacy/042.crlf.json b/resources/eml/legacy/042.crlf.json similarity index 100% rename from tests/legacy/042.crlf.json rename to resources/eml/legacy/042.crlf.json diff --git a/tests/legacy/042.eml b/resources/eml/legacy/042.eml similarity index 100% rename from tests/legacy/042.eml rename to resources/eml/legacy/042.eml diff --git a/tests/legacy/042.json b/resources/eml/legacy/042.json similarity index 100% rename from tests/legacy/042.json rename to resources/eml/legacy/042.json diff --git a/tests/legacy/043.crlf.json b/resources/eml/legacy/043.crlf.json similarity index 100% rename from tests/legacy/043.crlf.json rename to resources/eml/legacy/043.crlf.json diff --git a/tests/legacy/043.eml b/resources/eml/legacy/043.eml similarity index 100% rename from tests/legacy/043.eml rename to resources/eml/legacy/043.eml diff --git a/tests/legacy/043.json b/resources/eml/legacy/043.json similarity index 100% rename from tests/legacy/043.json rename to resources/eml/legacy/043.json diff --git a/tests/legacy/044.crlf.json b/resources/eml/legacy/044.crlf.json similarity index 100% rename from tests/legacy/044.crlf.json rename to resources/eml/legacy/044.crlf.json diff --git a/tests/legacy/044.eml b/resources/eml/legacy/044.eml similarity index 100% rename from tests/legacy/044.eml rename to resources/eml/legacy/044.eml diff --git a/tests/legacy/044.json b/resources/eml/legacy/044.json similarity index 100% rename from tests/legacy/044.json rename to resources/eml/legacy/044.json diff --git a/tests/legacy/045.crlf.json b/resources/eml/legacy/045.crlf.json similarity index 100% rename from tests/legacy/045.crlf.json rename to resources/eml/legacy/045.crlf.json diff --git a/tests/legacy/045.eml b/resources/eml/legacy/045.eml similarity index 100% rename from tests/legacy/045.eml rename to resources/eml/legacy/045.eml diff --git a/tests/legacy/045.json b/resources/eml/legacy/045.json similarity index 100% rename from tests/legacy/045.json rename to resources/eml/legacy/045.json diff --git a/tests/legacy/046.crlf.json b/resources/eml/legacy/046.crlf.json similarity index 100% rename from tests/legacy/046.crlf.json rename to resources/eml/legacy/046.crlf.json diff --git a/tests/legacy/046.eml b/resources/eml/legacy/046.eml similarity index 100% rename from tests/legacy/046.eml rename to resources/eml/legacy/046.eml diff --git a/tests/legacy/046.json b/resources/eml/legacy/046.json similarity index 100% rename from tests/legacy/046.json rename to resources/eml/legacy/046.json diff --git a/tests/legacy/047.crlf.json b/resources/eml/legacy/047.crlf.json similarity index 100% rename from tests/legacy/047.crlf.json rename to resources/eml/legacy/047.crlf.json diff --git a/tests/legacy/047.eml b/resources/eml/legacy/047.eml similarity index 100% rename from tests/legacy/047.eml rename to resources/eml/legacy/047.eml diff --git a/tests/legacy/047.json b/resources/eml/legacy/047.json similarity index 100% rename from tests/legacy/047.json rename to resources/eml/legacy/047.json diff --git a/tests/legacy/048.crlf.json b/resources/eml/legacy/048.crlf.json similarity index 100% rename from tests/legacy/048.crlf.json rename to resources/eml/legacy/048.crlf.json diff --git a/tests/legacy/048.eml b/resources/eml/legacy/048.eml similarity index 100% rename from tests/legacy/048.eml rename to resources/eml/legacy/048.eml diff --git a/tests/legacy/048.json b/resources/eml/legacy/048.json similarity index 100% rename from tests/legacy/048.json rename to resources/eml/legacy/048.json diff --git a/tests/legacy/049.crlf.json b/resources/eml/legacy/049.crlf.json similarity index 100% rename from tests/legacy/049.crlf.json rename to resources/eml/legacy/049.crlf.json diff --git a/tests/legacy/049.eml b/resources/eml/legacy/049.eml similarity index 100% rename from tests/legacy/049.eml rename to resources/eml/legacy/049.eml diff --git a/tests/legacy/049.json b/resources/eml/legacy/049.json similarity index 100% rename from tests/legacy/049.json rename to resources/eml/legacy/049.json diff --git a/tests/legacy/050.crlf.json b/resources/eml/legacy/050.crlf.json similarity index 100% rename from tests/legacy/050.crlf.json rename to resources/eml/legacy/050.crlf.json diff --git a/tests/legacy/050.eml b/resources/eml/legacy/050.eml similarity index 100% rename from tests/legacy/050.eml rename to resources/eml/legacy/050.eml diff --git a/tests/legacy/050.json b/resources/eml/legacy/050.json similarity index 100% rename from tests/legacy/050.json rename to resources/eml/legacy/050.json diff --git a/tests/legacy/051.crlf.json b/resources/eml/legacy/051.crlf.json similarity index 100% rename from tests/legacy/051.crlf.json rename to resources/eml/legacy/051.crlf.json diff --git a/tests/legacy/051.eml b/resources/eml/legacy/051.eml similarity index 100% rename from tests/legacy/051.eml rename to resources/eml/legacy/051.eml diff --git a/tests/legacy/051.json b/resources/eml/legacy/051.json similarity index 100% rename from tests/legacy/051.json rename to resources/eml/legacy/051.json diff --git a/tests/legacy/052.crlf.json b/resources/eml/legacy/052.crlf.json similarity index 100% rename from tests/legacy/052.crlf.json rename to resources/eml/legacy/052.crlf.json diff --git a/tests/legacy/052.eml b/resources/eml/legacy/052.eml similarity index 100% rename from tests/legacy/052.eml rename to resources/eml/legacy/052.eml diff --git a/tests/legacy/052.json b/resources/eml/legacy/052.json similarity index 100% rename from tests/legacy/052.json rename to resources/eml/legacy/052.json diff --git a/tests/legacy/053.crlf.json b/resources/eml/legacy/053.crlf.json similarity index 100% rename from tests/legacy/053.crlf.json rename to resources/eml/legacy/053.crlf.json diff --git a/tests/legacy/053.eml b/resources/eml/legacy/053.eml similarity index 100% rename from tests/legacy/053.eml rename to resources/eml/legacy/053.eml diff --git a/tests/legacy/053.json b/resources/eml/legacy/053.json similarity index 100% rename from tests/legacy/053.json rename to resources/eml/legacy/053.json diff --git a/tests/legacy/COPYING b/resources/eml/legacy/COPYING similarity index 100% rename from tests/legacy/COPYING rename to resources/eml/legacy/COPYING diff --git a/tests/malformed/000.crlf.json b/resources/eml/malformed/000.crlf.json similarity index 100% rename from tests/malformed/000.crlf.json rename to resources/eml/malformed/000.crlf.json diff --git a/tests/malformed/000.eml b/resources/eml/malformed/000.eml similarity index 100% rename from tests/malformed/000.eml rename to resources/eml/malformed/000.eml diff --git a/tests/malformed/000.json b/resources/eml/malformed/000.json similarity index 100% rename from tests/malformed/000.json rename to resources/eml/malformed/000.json diff --git a/tests/malformed/001.crlf.json b/resources/eml/malformed/001.crlf.json similarity index 100% rename from tests/malformed/001.crlf.json rename to resources/eml/malformed/001.crlf.json diff --git a/tests/malformed/001.eml b/resources/eml/malformed/001.eml similarity index 100% rename from tests/malformed/001.eml rename to resources/eml/malformed/001.eml diff --git a/tests/malformed/001.json b/resources/eml/malformed/001.json similarity index 100% rename from tests/malformed/001.json rename to resources/eml/malformed/001.json diff --git a/tests/malformed/002.crlf.json b/resources/eml/malformed/002.crlf.json similarity index 100% rename from tests/malformed/002.crlf.json rename to resources/eml/malformed/002.crlf.json diff --git a/tests/malformed/002.eml b/resources/eml/malformed/002.eml similarity index 100% rename from tests/malformed/002.eml rename to resources/eml/malformed/002.eml diff --git a/tests/malformed/002.json b/resources/eml/malformed/002.json similarity index 100% rename from tests/malformed/002.json rename to resources/eml/malformed/002.json diff --git a/tests/malformed/003.crlf.json b/resources/eml/malformed/003.crlf.json similarity index 100% rename from tests/malformed/003.crlf.json rename to resources/eml/malformed/003.crlf.json diff --git a/tests/malformed/003.eml b/resources/eml/malformed/003.eml similarity index 100% rename from tests/malformed/003.eml rename to resources/eml/malformed/003.eml diff --git a/tests/malformed/003.json b/resources/eml/malformed/003.json similarity index 100% rename from tests/malformed/003.json rename to resources/eml/malformed/003.json diff --git a/tests/malformed/004.crlf.json b/resources/eml/malformed/004.crlf.json similarity index 100% rename from tests/malformed/004.crlf.json rename to resources/eml/malformed/004.crlf.json diff --git a/tests/malformed/004.eml b/resources/eml/malformed/004.eml similarity index 100% rename from tests/malformed/004.eml rename to resources/eml/malformed/004.eml diff --git a/tests/malformed/004.json b/resources/eml/malformed/004.json similarity index 100% rename from tests/malformed/004.json rename to resources/eml/malformed/004.json diff --git a/tests/malformed/005.crlf.json b/resources/eml/malformed/005.crlf.json similarity index 100% rename from tests/malformed/005.crlf.json rename to resources/eml/malformed/005.crlf.json diff --git a/tests/malformed/005.eml b/resources/eml/malformed/005.eml similarity index 100% rename from tests/malformed/005.eml rename to resources/eml/malformed/005.eml diff --git a/tests/malformed/005.json b/resources/eml/malformed/005.json similarity index 100% rename from tests/malformed/005.json rename to resources/eml/malformed/005.json diff --git a/tests/malformed/006.crlf.json b/resources/eml/malformed/006.crlf.json similarity index 100% rename from tests/malformed/006.crlf.json rename to resources/eml/malformed/006.crlf.json diff --git a/tests/malformed/006.eml b/resources/eml/malformed/006.eml similarity index 100% rename from tests/malformed/006.eml rename to resources/eml/malformed/006.eml diff --git a/tests/malformed/006.json b/resources/eml/malformed/006.json similarity index 100% rename from tests/malformed/006.json rename to resources/eml/malformed/006.json diff --git a/tests/malformed/007.crlf.json b/resources/eml/malformed/007.crlf.json similarity index 100% rename from tests/malformed/007.crlf.json rename to resources/eml/malformed/007.crlf.json diff --git a/tests/malformed/007.eml b/resources/eml/malformed/007.eml similarity index 100% rename from tests/malformed/007.eml rename to resources/eml/malformed/007.eml diff --git a/tests/malformed/007.json b/resources/eml/malformed/007.json similarity index 100% rename from tests/malformed/007.json rename to resources/eml/malformed/007.json diff --git a/tests/malformed/008.crlf.json b/resources/eml/malformed/008.crlf.json similarity index 100% rename from tests/malformed/008.crlf.json rename to resources/eml/malformed/008.crlf.json diff --git a/tests/malformed/008.eml b/resources/eml/malformed/008.eml similarity index 100% rename from tests/malformed/008.eml rename to resources/eml/malformed/008.eml diff --git a/tests/malformed/008.json b/resources/eml/malformed/008.json similarity index 100% rename from tests/malformed/008.json rename to resources/eml/malformed/008.json diff --git a/tests/malformed/009.crlf.json b/resources/eml/malformed/009.crlf.json similarity index 100% rename from tests/malformed/009.crlf.json rename to resources/eml/malformed/009.crlf.json diff --git a/tests/malformed/009.eml b/resources/eml/malformed/009.eml similarity index 100% rename from tests/malformed/009.eml rename to resources/eml/malformed/009.eml diff --git a/tests/malformed/009.json b/resources/eml/malformed/009.json similarity index 100% rename from tests/malformed/009.json rename to resources/eml/malformed/009.json diff --git a/tests/malformed/010.crlf.json b/resources/eml/malformed/010.crlf.json similarity index 100% rename from tests/malformed/010.crlf.json rename to resources/eml/malformed/010.crlf.json diff --git a/tests/malformed/010.eml b/resources/eml/malformed/010.eml similarity index 100% rename from tests/malformed/010.eml rename to resources/eml/malformed/010.eml diff --git a/tests/malformed/010.json b/resources/eml/malformed/010.json similarity index 100% rename from tests/malformed/010.json rename to resources/eml/malformed/010.json diff --git a/tests/malformed/011.crlf.json b/resources/eml/malformed/011.crlf.json similarity index 100% rename from tests/malformed/011.crlf.json rename to resources/eml/malformed/011.crlf.json diff --git a/tests/malformed/011.eml b/resources/eml/malformed/011.eml similarity index 100% rename from tests/malformed/011.eml rename to resources/eml/malformed/011.eml diff --git a/tests/malformed/011.json b/resources/eml/malformed/011.json similarity index 100% rename from tests/malformed/011.json rename to resources/eml/malformed/011.json diff --git a/tests/malformed/012.crlf.json b/resources/eml/malformed/012.crlf.json similarity index 100% rename from tests/malformed/012.crlf.json rename to resources/eml/malformed/012.crlf.json diff --git a/tests/malformed/012.eml b/resources/eml/malformed/012.eml similarity index 100% rename from tests/malformed/012.eml rename to resources/eml/malformed/012.eml diff --git a/tests/malformed/012.json b/resources/eml/malformed/012.json similarity index 100% rename from tests/malformed/012.json rename to resources/eml/malformed/012.json diff --git a/tests/malformed/013.crlf.json b/resources/eml/malformed/013.crlf.json similarity index 100% rename from tests/malformed/013.crlf.json rename to resources/eml/malformed/013.crlf.json diff --git a/tests/malformed/013.eml b/resources/eml/malformed/013.eml similarity index 100% rename from tests/malformed/013.eml rename to resources/eml/malformed/013.eml diff --git a/tests/malformed/013.json b/resources/eml/malformed/013.json similarity index 100% rename from tests/malformed/013.json rename to resources/eml/malformed/013.json diff --git a/tests/malformed/014.crlf.json b/resources/eml/malformed/014.crlf.json similarity index 100% rename from tests/malformed/014.crlf.json rename to resources/eml/malformed/014.crlf.json diff --git a/tests/malformed/014.eml b/resources/eml/malformed/014.eml similarity index 100% rename from tests/malformed/014.eml rename to resources/eml/malformed/014.eml diff --git a/tests/malformed/014.json b/resources/eml/malformed/014.json similarity index 100% rename from tests/malformed/014.json rename to resources/eml/malformed/014.json diff --git a/tests/malformed/015.crlf.json b/resources/eml/malformed/015.crlf.json similarity index 100% rename from tests/malformed/015.crlf.json rename to resources/eml/malformed/015.crlf.json diff --git a/tests/malformed/015.eml b/resources/eml/malformed/015.eml similarity index 100% rename from tests/malformed/015.eml rename to resources/eml/malformed/015.eml diff --git a/tests/malformed/015.json b/resources/eml/malformed/015.json similarity index 100% rename from tests/malformed/015.json rename to resources/eml/malformed/015.json diff --git a/tests/malformed/016.crlf.json b/resources/eml/malformed/016.crlf.json similarity index 100% rename from tests/malformed/016.crlf.json rename to resources/eml/malformed/016.crlf.json diff --git a/tests/malformed/016.eml b/resources/eml/malformed/016.eml similarity index 100% rename from tests/malformed/016.eml rename to resources/eml/malformed/016.eml diff --git a/tests/malformed/016.json b/resources/eml/malformed/016.json similarity index 100% rename from tests/malformed/016.json rename to resources/eml/malformed/016.json diff --git a/tests/malformed/COPYING b/resources/eml/malformed/COPYING similarity index 100% rename from tests/malformed/COPYING rename to resources/eml/malformed/COPYING diff --git a/tests/rfc/000.crlf.json b/resources/eml/rfc/000.crlf.json similarity index 100% rename from tests/rfc/000.crlf.json rename to resources/eml/rfc/000.crlf.json diff --git a/tests/rfc/000.eml b/resources/eml/rfc/000.eml similarity index 100% rename from tests/rfc/000.eml rename to resources/eml/rfc/000.eml diff --git a/tests/rfc/000.json b/resources/eml/rfc/000.json similarity index 100% rename from tests/rfc/000.json rename to resources/eml/rfc/000.json diff --git a/tests/rfc/001.crlf.json b/resources/eml/rfc/001.crlf.json similarity index 100% rename from tests/rfc/001.crlf.json rename to resources/eml/rfc/001.crlf.json diff --git a/tests/rfc/001.eml b/resources/eml/rfc/001.eml similarity index 100% rename from tests/rfc/001.eml rename to resources/eml/rfc/001.eml diff --git a/tests/rfc/001.json b/resources/eml/rfc/001.json similarity index 100% rename from tests/rfc/001.json rename to resources/eml/rfc/001.json diff --git a/tests/rfc/002.crlf.json b/resources/eml/rfc/002.crlf.json similarity index 100% rename from tests/rfc/002.crlf.json rename to resources/eml/rfc/002.crlf.json diff --git a/tests/rfc/002.eml b/resources/eml/rfc/002.eml similarity index 100% rename from tests/rfc/002.eml rename to resources/eml/rfc/002.eml diff --git a/tests/rfc/002.json b/resources/eml/rfc/002.json similarity index 100% rename from tests/rfc/002.json rename to resources/eml/rfc/002.json diff --git a/tests/rfc/003.crlf.json b/resources/eml/rfc/003.crlf.json similarity index 100% rename from tests/rfc/003.crlf.json rename to resources/eml/rfc/003.crlf.json diff --git a/tests/rfc/003.eml b/resources/eml/rfc/003.eml similarity index 100% rename from tests/rfc/003.eml rename to resources/eml/rfc/003.eml diff --git a/tests/rfc/003.json b/resources/eml/rfc/003.json similarity index 100% rename from tests/rfc/003.json rename to resources/eml/rfc/003.json diff --git a/tests/rfc/004.crlf.json b/resources/eml/rfc/004.crlf.json similarity index 100% rename from tests/rfc/004.crlf.json rename to resources/eml/rfc/004.crlf.json diff --git a/tests/rfc/004.eml b/resources/eml/rfc/004.eml similarity index 100% rename from tests/rfc/004.eml rename to resources/eml/rfc/004.eml diff --git a/tests/rfc/004.json b/resources/eml/rfc/004.json similarity index 100% rename from tests/rfc/004.json rename to resources/eml/rfc/004.json diff --git a/tests/rfc/005.crlf.json b/resources/eml/rfc/005.crlf.json similarity index 100% rename from tests/rfc/005.crlf.json rename to resources/eml/rfc/005.crlf.json diff --git a/tests/rfc/005.eml b/resources/eml/rfc/005.eml similarity index 100% rename from tests/rfc/005.eml rename to resources/eml/rfc/005.eml diff --git a/tests/rfc/005.json b/resources/eml/rfc/005.json similarity index 100% rename from tests/rfc/005.json rename to resources/eml/rfc/005.json diff --git a/tests/rfc/006.crlf.json b/resources/eml/rfc/006.crlf.json similarity index 100% rename from tests/rfc/006.crlf.json rename to resources/eml/rfc/006.crlf.json diff --git a/tests/rfc/006.eml b/resources/eml/rfc/006.eml similarity index 100% rename from tests/rfc/006.eml rename to resources/eml/rfc/006.eml diff --git a/tests/rfc/006.json b/resources/eml/rfc/006.json similarity index 100% rename from tests/rfc/006.json rename to resources/eml/rfc/006.json diff --git a/tests/rfc/007.crlf.json b/resources/eml/rfc/007.crlf.json similarity index 100% rename from tests/rfc/007.crlf.json rename to resources/eml/rfc/007.crlf.json diff --git a/tests/rfc/007.eml b/resources/eml/rfc/007.eml similarity index 100% rename from tests/rfc/007.eml rename to resources/eml/rfc/007.eml diff --git a/tests/rfc/007.json b/resources/eml/rfc/007.json similarity index 100% rename from tests/rfc/007.json rename to resources/eml/rfc/007.json diff --git a/tests/rfc/008.crlf.json b/resources/eml/rfc/008.crlf.json similarity index 100% rename from tests/rfc/008.crlf.json rename to resources/eml/rfc/008.crlf.json diff --git a/tests/rfc/008.eml b/resources/eml/rfc/008.eml similarity index 100% rename from tests/rfc/008.eml rename to resources/eml/rfc/008.eml diff --git a/tests/rfc/008.json b/resources/eml/rfc/008.json similarity index 100% rename from tests/rfc/008.json rename to resources/eml/rfc/008.json diff --git a/tests/rfc/009.crlf.json b/resources/eml/rfc/009.crlf.json similarity index 100% rename from tests/rfc/009.crlf.json rename to resources/eml/rfc/009.crlf.json diff --git a/tests/rfc/009.eml b/resources/eml/rfc/009.eml similarity index 100% rename from tests/rfc/009.eml rename to resources/eml/rfc/009.eml diff --git a/tests/rfc/009.json b/resources/eml/rfc/009.json similarity index 100% rename from tests/rfc/009.json rename to resources/eml/rfc/009.json diff --git a/tests/thirdparty/000.crlf.json b/resources/eml/thirdparty/000.crlf.json similarity index 100% rename from tests/thirdparty/000.crlf.json rename to resources/eml/thirdparty/000.crlf.json diff --git a/tests/thirdparty/000.eml b/resources/eml/thirdparty/000.eml similarity index 100% rename from tests/thirdparty/000.eml rename to resources/eml/thirdparty/000.eml diff --git a/tests/thirdparty/000.json b/resources/eml/thirdparty/000.json similarity index 100% rename from tests/thirdparty/000.json rename to resources/eml/thirdparty/000.json diff --git a/tests/thirdparty/001.crlf.json b/resources/eml/thirdparty/001.crlf.json similarity index 100% rename from tests/thirdparty/001.crlf.json rename to resources/eml/thirdparty/001.crlf.json diff --git a/tests/thirdparty/001.eml b/resources/eml/thirdparty/001.eml similarity index 100% rename from tests/thirdparty/001.eml rename to resources/eml/thirdparty/001.eml diff --git a/tests/thirdparty/001.json b/resources/eml/thirdparty/001.json similarity index 100% rename from tests/thirdparty/001.json rename to resources/eml/thirdparty/001.json diff --git a/tests/thirdparty/002.crlf.json b/resources/eml/thirdparty/002.crlf.json similarity index 100% rename from tests/thirdparty/002.crlf.json rename to resources/eml/thirdparty/002.crlf.json diff --git a/tests/thirdparty/002.eml b/resources/eml/thirdparty/002.eml similarity index 100% rename from tests/thirdparty/002.eml rename to resources/eml/thirdparty/002.eml diff --git a/tests/thirdparty/002.json b/resources/eml/thirdparty/002.json similarity index 100% rename from tests/thirdparty/002.json rename to resources/eml/thirdparty/002.json diff --git a/tests/thirdparty/003.crlf.json b/resources/eml/thirdparty/003.crlf.json similarity index 100% rename from tests/thirdparty/003.crlf.json rename to resources/eml/thirdparty/003.crlf.json diff --git a/tests/thirdparty/003.eml b/resources/eml/thirdparty/003.eml similarity index 100% rename from tests/thirdparty/003.eml rename to resources/eml/thirdparty/003.eml diff --git a/tests/thirdparty/003.json b/resources/eml/thirdparty/003.json similarity index 100% rename from tests/thirdparty/003.json rename to resources/eml/thirdparty/003.json diff --git a/tests/thirdparty/004.crlf.json b/resources/eml/thirdparty/004.crlf.json similarity index 100% rename from tests/thirdparty/004.crlf.json rename to resources/eml/thirdparty/004.crlf.json diff --git a/tests/thirdparty/004.eml b/resources/eml/thirdparty/004.eml similarity index 100% rename from tests/thirdparty/004.eml rename to resources/eml/thirdparty/004.eml diff --git a/tests/thirdparty/004.json b/resources/eml/thirdparty/004.json similarity index 100% rename from tests/thirdparty/004.json rename to resources/eml/thirdparty/004.json diff --git a/tests/thirdparty/005.crlf.json b/resources/eml/thirdparty/005.crlf.json similarity index 100% rename from tests/thirdparty/005.crlf.json rename to resources/eml/thirdparty/005.crlf.json diff --git a/tests/thirdparty/005.eml b/resources/eml/thirdparty/005.eml similarity index 100% rename from tests/thirdparty/005.eml rename to resources/eml/thirdparty/005.eml diff --git a/tests/thirdparty/005.json b/resources/eml/thirdparty/005.json similarity index 100% rename from tests/thirdparty/005.json rename to resources/eml/thirdparty/005.json diff --git a/tests/thirdparty/006.crlf.json b/resources/eml/thirdparty/006.crlf.json similarity index 100% rename from tests/thirdparty/006.crlf.json rename to resources/eml/thirdparty/006.crlf.json diff --git a/tests/thirdparty/006.eml b/resources/eml/thirdparty/006.eml similarity index 100% rename from tests/thirdparty/006.eml rename to resources/eml/thirdparty/006.eml diff --git a/tests/thirdparty/006.json b/resources/eml/thirdparty/006.json similarity index 100% rename from tests/thirdparty/006.json rename to resources/eml/thirdparty/006.json diff --git a/tests/thirdparty/007.crlf.json b/resources/eml/thirdparty/007.crlf.json similarity index 100% rename from tests/thirdparty/007.crlf.json rename to resources/eml/thirdparty/007.crlf.json diff --git a/tests/thirdparty/007.eml b/resources/eml/thirdparty/007.eml similarity index 100% rename from tests/thirdparty/007.eml rename to resources/eml/thirdparty/007.eml diff --git a/tests/thirdparty/007.json b/resources/eml/thirdparty/007.json similarity index 100% rename from tests/thirdparty/007.json rename to resources/eml/thirdparty/007.json diff --git a/tests/thirdparty/008.crlf.json b/resources/eml/thirdparty/008.crlf.json similarity index 100% rename from tests/thirdparty/008.crlf.json rename to resources/eml/thirdparty/008.crlf.json diff --git a/tests/thirdparty/008.eml b/resources/eml/thirdparty/008.eml similarity index 100% rename from tests/thirdparty/008.eml rename to resources/eml/thirdparty/008.eml diff --git a/tests/thirdparty/008.json b/resources/eml/thirdparty/008.json similarity index 100% rename from tests/thirdparty/008.json rename to resources/eml/thirdparty/008.json diff --git a/tests/thirdparty/009.crlf.json b/resources/eml/thirdparty/009.crlf.json similarity index 100% rename from tests/thirdparty/009.crlf.json rename to resources/eml/thirdparty/009.crlf.json diff --git a/tests/thirdparty/009.eml b/resources/eml/thirdparty/009.eml similarity index 100% rename from tests/thirdparty/009.eml rename to resources/eml/thirdparty/009.eml diff --git a/tests/thirdparty/009.json b/resources/eml/thirdparty/009.json similarity index 100% rename from tests/thirdparty/009.json rename to resources/eml/thirdparty/009.json diff --git a/tests/thirdparty/010.crlf.json b/resources/eml/thirdparty/010.crlf.json similarity index 100% rename from tests/thirdparty/010.crlf.json rename to resources/eml/thirdparty/010.crlf.json diff --git a/tests/thirdparty/010.eml b/resources/eml/thirdparty/010.eml similarity index 100% rename from tests/thirdparty/010.eml rename to resources/eml/thirdparty/010.eml diff --git a/tests/thirdparty/010.json b/resources/eml/thirdparty/010.json similarity index 100% rename from tests/thirdparty/010.json rename to resources/eml/thirdparty/010.json diff --git a/tests/thirdparty/011.crlf.json b/resources/eml/thirdparty/011.crlf.json similarity index 100% rename from tests/thirdparty/011.crlf.json rename to resources/eml/thirdparty/011.crlf.json diff --git a/tests/thirdparty/011.eml b/resources/eml/thirdparty/011.eml similarity index 100% rename from tests/thirdparty/011.eml rename to resources/eml/thirdparty/011.eml diff --git a/tests/thirdparty/011.json b/resources/eml/thirdparty/011.json similarity index 100% rename from tests/thirdparty/011.json rename to resources/eml/thirdparty/011.json diff --git a/tests/thirdparty/012.crlf.json b/resources/eml/thirdparty/012.crlf.json similarity index 100% rename from tests/thirdparty/012.crlf.json rename to resources/eml/thirdparty/012.crlf.json diff --git a/tests/thirdparty/012.eml b/resources/eml/thirdparty/012.eml similarity index 100% rename from tests/thirdparty/012.eml rename to resources/eml/thirdparty/012.eml diff --git a/tests/thirdparty/012.json b/resources/eml/thirdparty/012.json similarity index 100% rename from tests/thirdparty/012.json rename to resources/eml/thirdparty/012.json diff --git a/tests/thirdparty/013.crlf.json b/resources/eml/thirdparty/013.crlf.json similarity index 100% rename from tests/thirdparty/013.crlf.json rename to resources/eml/thirdparty/013.crlf.json diff --git a/tests/thirdparty/013.eml b/resources/eml/thirdparty/013.eml similarity index 100% rename from tests/thirdparty/013.eml rename to resources/eml/thirdparty/013.eml diff --git a/tests/thirdparty/013.json b/resources/eml/thirdparty/013.json similarity index 100% rename from tests/thirdparty/013.json rename to resources/eml/thirdparty/013.json diff --git a/tests/thirdparty/COPYING b/resources/eml/thirdparty/COPYING similarity index 100% rename from tests/thirdparty/COPYING rename to resources/eml/thirdparty/COPYING diff --git a/tests/maildir/.My Folder.Nested Folder/cur/1276533073.M242911P3632.kurkku;2,FP b/resources/maildir/.My Folder.Nested Folder/cur/1276533073.M242911P3632.kurkku;2,FP similarity index 100% rename from tests/maildir/.My Folder.Nested Folder/cur/1276533073.M242911P3632.kurkku;2,FP rename to resources/maildir/.My Folder.Nested Folder/cur/1276533073.M242911P3632.kurkku;2,FP diff --git a/tests/maildir/.My Folder.Nested Folder/new/1035478339.27041_118.foo.org,S=1000,W=1030;2,RDF, b/resources/maildir/.My Folder.Nested Folder/new/1035478339.27041_118.foo.org,S=1000,W=1030;2,RDF, similarity index 100% rename from tests/maildir/.My Folder.Nested Folder/new/1035478339.27041_118.foo.org,S=1000,W=1030;2,RDF, rename to resources/maildir/.My Folder.Nested Folder/new/1035478339.27041_118.foo.org,S=1000,W=1030;2,RDF, diff --git a/tests/maildir/.My Folder/cur/1035478339.27041_118.foo.org,S=1000,W=1030;2,TDR b/resources/maildir/.My Folder/cur/1035478339.27041_118.foo.org,S=1000,W=1030;2,TDR similarity index 100% rename from tests/maildir/.My Folder/cur/1035478339.27041_118.foo.org,S=1000,W=1030;2,TDR rename to resources/maildir/.My Folder/cur/1035478339.27041_118.foo.org,S=1000,W=1030;2,TDR diff --git a/tests/maildir/.My Folder/new/1276528487.M364837P9451.kurkku,S=1355,W=1394;2, b/resources/maildir/.My Folder/new/1276528487.M364837P9451.kurkku,S=1355,W=1394;2, similarity index 100% rename from tests/maildir/.My Folder/new/1276528487.M364837P9451.kurkku,S=1355,W=1394;2, rename to resources/maildir/.My Folder/new/1276528487.M364837P9451.kurkku,S=1355,W=1394;2, diff --git a/tests/maildir/cur/1491941793.M41850P8566V0000000000000015I0000000004F3030E_0.mx1.example.com,S=10956;2,STln b/resources/maildir/cur/1491941793.M41850P8566V0000000000000015I0000000004F3030E_0.mx1.example.com,S=10956;2,STln similarity index 100% rename from tests/maildir/cur/1491941793.M41850P8566V0000000000000015I0000000004F3030E_0.mx1.example.com,S=10956;2,STln rename to resources/maildir/cur/1491941793.M41850P8566V0000000000000015I0000000004F3030E_0.mx1.example.com,S=10956;2,STln diff --git a/tests/maildir/new/1234567890.M20046P2137.mailserver,S=4542,W=4642;2,Sb b/resources/maildir/new/1234567890.M20046P2137.mailserver,S=4542,W=4642;2,Sb similarity index 100% rename from tests/maildir/new/1234567890.M20046P2137.mailserver,S=4542,W=4642;2,Sb rename to resources/maildir/new/1234567890.M20046P2137.mailserver,S=4542,W=4642;2,Sb diff --git a/resources/received.json b/resources/received.json new file mode 100644 index 0000000..4c9161a --- /dev/null +++ b/resources/received.json @@ -0,0 +1,4204 @@ +[ + { + "header": "from unknown (HELO MP61M.F-I.DE) () by p01ev.mail.s-web.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2023 04:24:06 +0200\n", + "expected": { + "from": { + "Name": "unknown" + }, + "by": { + "Name": "p01ev.mail.s-web.de" + }, + "with": "ESMTP", + "tls_cipher": "DHE-RSA-AES256-GCM-SHA384", + "helo": { + "Name": "MP61M.F-I.DE" + }, + "helo_cmd": "Helo", + "date": { + "year": 2023, + "month": 9, + "day": 2, + "hour": 4, + "minute": 24, + "second": 6, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from NODE50.F-I.DE (NODE50) by MP61M.F-I.DE (MP61 ) for with ESMTP (IBM TCMCSEPO z/OS V02R05.00) Id MP61M.20230902.020403.767296.121.91633@F-I.DE ; Sat, 02 Sep 2023 02:04:03 +0200\n", + "expected": { + "from": { + "Name": "NODE50.F-I.DE" + }, + "by": { + "Name": "MP61M.F-I.DE" + }, + "for_": "TCMCSEPO@NODE50", + "with": "ESMTP", + "id": "MP61M.20230902.020403.767296.121.91633@F-I.DE", + "date": { + "year": 2023, + "month": 9, + "day": 2, + "hour": 2, + "minute": 4, + "second": 3, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from out-25.smtp.github.com (out-25.smtp.github.com. [192.30.252.208]) (using TLSv1.3 with cipher TLS13_AES_256_GCM_SHA384)\r\n\t by mail.stalw.art (Stalwart SMTP) with ESMTPS id 41A2C80D73C;\r\n\tTue, 29 Aug 2023 16:20:12 +0000\n", + "expected": { + "from": { + "Name": "out-25.smtp.github.com" + }, + "from_ip": "192.30.252.208", + "from_iprev": "out-25.smtp.github.com.", + "by": { + "Name": "mail.stalw.art" + }, + "with": "ESMTPS", + "tls_version": "TLSv1_3", + "tls_cipher": "TLS13_AES_256_GCM_SHA384", + "id": "41A2C80D73C", + "date": { + "year": 2023, + "month": 8, + "day": 29, + "hour": 16, + "minute": 20, + "second": 12, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from github.com (hubbernetes-node-c032927.ash1-iad.github.net [10.56.145.42]) by smtp.github.com (Postfix) with ESMTPA id B4E173410F4 for ; Tue, 29 Aug 2023 09:20:10 -0700 (PDT)\n", + "expected": { + "from": { + "Name": "github.com" + }, + "from_ip": "10.56.145.42", + "from_iprev": "hubbernetes-node-c032927.ash1-iad.github.net", + "by": { + "Name": "smtp.github.com" + }, + "for_": "hello@stalw.art", + "with": "ESMTPA", + "id": "B4E173410F4", + "date": { + "year": 2023, + "month": 8, + "day": 29, + "hour": 9, + "minute": 20, + "second": 10, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from ietfa.amsl.com (localhost [IPv6:::1]) by ietfa.amsl.com (Postfix) with ESMTP id 6296FC13AE3E for ; Mon, 28 Aug 2023 02:21:37 -0700 (PDT)\n", + "expected": { + "from": { + "Name": "ietfa.amsl.com" + }, + "from_ip": "::1", + "by": { + "Name": "ietfa.amsl.com" + }, + "for_": "hello@domain.comt", + "with": "ESMTP", + "id": "6296FC13AE3E", + "date": { + "year": 2023, + "month": 8, + "day": 28, + "hour": 2, + "minute": 21, + "second": 37, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from wmail.tana.it (wmail.tana.it [94.198.96.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 10B7AC151535 for ; Mon, 28 Aug 2023 02:21:23 -0700 (PDT)\n", + "expected": { + "from": { + "Name": "wmail.tana.it" + }, + "from_ip": "94.198.96.74", + "from_iprev": "wmail.tana.it", + "by": { + "Name": "ietfa.amsl.com" + }, + "for_": "dmarc@ietf.org", + "with": "ESMTPS", + "tls_version": "TLSv1_3", + "tls_cipher": "TLS_AES_256_GCM_SHA384", + "id": "10B7AC151535", + "date": { + "year": 2023, + "month": 8, + "day": 28, + "hour": 2, + "minute": 21, + "second": 23, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from [172.25.197.120] (pcale.tana [172.25.197.120]) (AUTH: CRAM-MD5 uXDGrn@SYT0/k, TLS: TLS1.3, 128bits, ECDHE_RSA_AES_128_GCM_SHA256) by wmail.tana.it with ESMTPSA id 00000000005DC0D6.0000000064EC6711.00003756; Mon, 28 Aug 2023 11:21:21 +0200\n", + "expected": { + "from": { + "IpAddr": "172.25.197.120" + }, + "from_ip": "172.25.197.120", + "from_iprev": "pcale.tana", + "by": { + "Name": "wmail.tana.it" + }, + "with": "ESMTPSA", + "tls_version": "TLSv1_3", + "tls_cipher": "ECDHE_RSA_AES_128_GCM_SHA256", + "id": "00000000005DC0D6.0000000064EC6711.00003756", + "ident": "uXDGrn@SYT0", + "date": { + "year": 2023, + "month": 8, + "day": 28, + "hour": 11, + "minute": 21, + "second": 21, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from gal.iecc.com (gal.iecc.com [IPv6:2001:470:1f07:1126:0:43:6f73:7461]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id C95E9C151087 for ; Sun, 27 Aug 2023 03:00:06 -0700 (PDT)\n", + "expected": { + "from": { + "Name": "gal.iecc.com" + }, + "from_ip": "2001:470:1f07:1126:0:43:6f73:7461", + "from_iprev": "gal.iecc.com", + "by": { + "Name": "ietfa.amsl.com" + }, + "for_": "dmarc@ietf.org", + "with": "ESMTPS", + "tls_version": "TLSv1_3", + "tls_cipher": "TLS_AES_256_GCM_SHA384", + "id": "C95E9C151087", + "date": { + "year": 2023, + "month": 8, + "day": 27, + "hour": 3, + "minute": 0, + "second": 6, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from infodrom.org by finlandia.Infodrom.North.DE via smail from stdin id for debian-security-announce@lists.debian.org; Thu, 18 May 2006 18:28:08 +0200 (CEST)\n", + "expected": { + "from": { + "Name": "infodrom.org" + }, + "by": { + "Name": "finlandia.Infodrom.North.DE" + }, + "for_": "debian-security-announce@lists.debian.org", + "id": "m1FglM8-000okjC@finlandia.Infodrom.North.DE", + "via": "smail", + "date": { + "year": 2006, + "month": 5, + "day": 18, + "hour": 18, + "minute": 28, + "second": 8, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from wilhelm.eyp.ee with ESMTP id h1I7hGU06122 for ; Tue, 18 Feb 2003 09:43:16 +0200\n", + "expected": { + "from": { + "Name": "wilhelm.eyp.ee" + }, + "for_": "spamassassin-talk@lists.sourceforge.net", + "with": "ESMTP", + "id": "h1I7hGU06122", + "date": { + "year": 2003, + "month": 2, + "day": 18, + "hour": 9, + "minute": 43, + "second": 16, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from www-data by wwwmail.documenta.de (Exim 4.50) with local for id 1GFbZc-0006QV-L8; Tue, 22 Aug 2006 21:06:04 +0200\n", + "expected": { + "from": { + "Name": "www-data" + }, + "by": { + "Name": "wwwmail.documenta.de" + }, + "for_": "example@vandinter.org", + "with": "Local", + "id": "1GFbZc-0006QV-L8", + "date": { + "year": 2006, + "month": 8, + "day": 22, + "hour": 21, + "minute": 6, + "second": 4, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from server.yourhostingaccount.com with local for example@vandinter.org id 1GDtdl-0002GU-QE (8710); Thu, 17 Aug 2006 21:59:17 -0400\n", + "expected": { + "from": { + "Name": "server.yourhostingaccount.com" + }, + "for_": "example@vandinter.org", + "with": "Local", + "id": "1GDtdl-0002GU-QE", + "date": { + "year": 2006, + "month": 8, + "day": 17, + "hour": 21, + "minute": 59, + "second": 17, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from virtual-access.org by bolero.conactive.com ; Thu, 20 Feb 2003 23:32:58 +0100\n", + "expected": { + "from": { + "Name": "virtual-access.org" + }, + "by": { + "Name": "bolero.conactive.com" + }, + "date": { + "year": 2003, + "month": 2, + "day": 20, + "hour": 23, + "minute": 32, + "second": 58, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "FROM ca-ex-bridge1.nai.com BY scwsout1.nai.com ; Fri Feb 07 10:18:12 2003 -0800\n", + "expected": { + "from": { + "Name": "ca-ex-bridge1.nai.com" + }, + "by": { + "Name": "scwsout1.nai.com" + }, + "date": { + "year": 1910, + "month": 7, + "day": 2, + "hour": 18, + "minute": 12, + "second": 211, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from [86.122.158.69] by mta2.iomartmail.com; Thu, 2 Aug 2007 21:50:04 -0200\n", + "expected": { + "from": { + "IpAddr": "86.122.158.69" + }, + "by": { + "Name": "mta2.iomartmail.com" + }, + "date": { + "year": 2007, + "month": 8, + "day": 2, + "hour": 21, + "minute": 50, + "second": 4, + "tz_before_gmt": true, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from av0001.technodiva.com (localhost [127.0.0.1])by localhost.technodiva.com (Postfix) with ESMTP id 846CF2117for ; Mon, 7 Aug 2006 17:48:07 +0200 (MEST)\n", + "expected": { + "from": { + "Name": "av0001.technodiva.com" + }, + "from_ip": "127.0.0.1", + "by": { + "Name": "localhost.technodiva.com" + }, + "with": "ESMTP", + "id": "846CF2117for", + "date": { + "year": 2006, + "month": 8, + "day": 7, + "hour": 17, + "minute": 48, + "second": 7, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from 142.169.110.122 (SquirrelMail authenticated user synapse) by mail.nomis80.org with HTTP; Sat, 3 Apr 2004 10:33:43 -0500 (EST)\n", + "expected": { + "from": { + "IpAddr": "142.169.110.122" + }, + "by": { + "Name": "mail.nomis80.org" + }, + "with": "HTTP", + "date": { + "year": 2004, + "month": 4, + "day": 3, + "hour": 10, + "minute": 33, + "second": 43, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from 82.135.198.129 by FWM-M18.sysops.aol.com (64.12.168.82) with HTTP (WebMailUI); Tue, 19 Jun 2007 11:16:54 -0400\n", + "expected": { + "from": { + "IpAddr": "82.135.198.129" + }, + "by": { + "Name": "FWM-M18.sysops.aol.com" + }, + "with": "HTTP", + "date": { + "year": 2007, + "month": 6, + "day": 19, + "hour": 11, + "minute": 16, + "second": 54, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from inet-vrs-05.redmond.corp.microsoft.com ([157.54.6.157]) by INET-IMC-05.redmond.corp.microsoft.com with Microsoft SMTPSVC(5.0.2195.6624); Thu, 6 Mar 2003 12:02:35 -0800\n", + "expected": { + "from": { + "Name": "inet-vrs-05.redmond.corp.microsoft.com" + }, + "from_ip": "157.54.6.157", + "by": { + "Name": "INET-IMC-05.redmond.corp.microsoft.com" + }, + "with": "SMTP", + "date": { + "year": 2003, + "month": 3, + "day": 6, + "hour": 12, + "minute": 2, + "second": 35, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from 0 ([61.31.135.91]) by bass.bass.com.eg with Microsoft SMTPSVC(5.0.2195.6713); Tue, 21 Sep 2004 08:59:06 +0300\n", + "expected": { + "from": { + "Name": "0" + }, + "from_ip": "61.31.135.91", + "by": { + "Name": "bass.bass.com.eg" + }, + "with": "SMTP", + "date": { + "year": 2004, + "month": 9, + "day": 21, + "hour": 8, + "minute": 59, + "second": 6, + "tz_before_gmt": false, + "tz_hour": 3, + "tz_minute": 0 + } + } + }, + { + "header": "from 0 ([61.31.138.57] RDNS failed) by nccdi.com with Microsoft SMTPSVC(6.0.3790.0); Thu, 23 Sep 2004 08:51:06 -0700\n", + "expected": { + "from": { + "Name": "0" + }, + "from_ip": "61.31.138.57", + "by": { + "Name": "nccdi.com" + }, + "with": "SMTP", + "date": { + "year": 2004, + "month": 9, + "day": 23, + "hour": 8, + "minute": 51, + "second": 6, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from tthompson ([217.35.105.172] unverified) by mail.neosinteractive.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 11 Mar 2003 13:23:01 +0000\n", + "expected": { + "from": { + "Name": "tthompson" + }, + "from_ip": "217.35.105.172", + "by": { + "Name": "mail.neosinteractive.com" + }, + "with": "SMTP", + "date": { + "year": 2003, + "month": 3, + "day": 11, + "hour": 13, + "minute": 23, + "second": 1, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from ([172.16.1.78]) by email2.codeworksonline.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 6 Sep 2006 21:14:29 -0400\n", + "expected": { + "from_ip": "172.16.1.78", + "by": { + "Name": "email2.codeworksonline.com" + }, + "with": "SMTP", + "date": { + "year": 2006, + "month": 9, + "day": 6, + "hour": 21, + "minute": 14, + "second": 29, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from mail pickup service by mail1.insuranceiq.com with Microsoft SMTPSVC; Thu, 13 Feb 2003 19:05:39 -0500\n", + "expected": { + "from": { + "Name": "mail" + }, + "by": { + "Name": "mail1.insuranceiq.com" + }, + "with": "SMTP", + "date": { + "year": 2003, + "month": 2, + "day": 13, + "hour": 19, + "minute": 5, + "second": 39, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from EXC-DAG-02.global.net (10.45.252.152) by EXC-DAG-02.global.net (10.45.252.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Mon, 29 Oct 2018 11:17:19 +0100\n", + "expected": { + "from": { + "Name": "EXC-DAG-02.global.net" + }, + "from_ip": "10.45.252.152", + "by": { + "Name": "EXC-DAG-02.global.net" + }, + "with": "SMTP", + "tls_version": "TLSv1_2", + "tls_cipher": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "id": "15.1.1261.35", + "date": { + "year": 2018, + "month": 10, + "day": 29, + "hour": 11, + "minute": 17, + "second": 19, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from AM5PR0402MB2836.eurprd04.prod.outlook.com ([fe80::19bd:c588:dd17:5226]) by AM5PR0402MB2836.eurprd04.prod.outlook.com ([fe80::19bd:c588:dd17:5226%6]) with mapi id 15.20.1943.023; Wed, 5 Jun 2019 10:17:08 +0000\n", + "expected": { + "from": { + "Name": "AM5PR0402MB2836.eurprd04.prod.outlook.com" + }, + "from_ip": "fe80::19bd:c588:dd17:5226", + "by": { + "Name": "AM5PR0402MB2836.eurprd04.prod.outlook.com" + }, + "id": "15.20.1943.023", + "date": { + "year": 2019, + "month": 6, + "day": 5, + "hour": 10, + "minute": 17, + "second": 8, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from list.brainbuzz.com (63.146.189.86:23198) by mx1.yourtech.net with [XMail 1.20 ESMTP Server] id for from ; Sat, 18 Sep 2004 23:17:54 -0500\n", + "expected": { + "from": { + "Name": "list.brainbuzz.com" + }, + "from_ip": "63.146.189.86", + "by": { + "Name": "mx1.yourtech.net" + }, + "for_": "jason@ellingson.org.spamassassin.org", + "with": "ESMTP", + "id": "S72E", + "date": { + "year": 2004, + "month": 9, + "day": 18, + "hour": 23, + "minute": 17, + "second": 54, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from list.brainbuzz.com (63.146.189.86:23198) by mx1.yourtech.net (209.32.147.34:25) with [XMail 1.20 ESMTP Server] id for from ; Sat, 18 Sep 2004 23:17:54 -0500\n", + "expected": { + "from": { + "Name": "list.brainbuzz.com" + }, + "from_ip": "63.146.189.86", + "by": { + "Name": "mx1.yourtech.net" + }, + "for_": "jason@ellingson.org.spamassassin.org", + "with": "ESMTP", + "id": "S72E", + "date": { + "year": 2004, + "month": 9, + "day": 18, + "hour": 23, + "minute": 17, + "second": 54, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from ([10.225.209.19:33672]) by ecelerity-va-1 (ecelerity HEAD) with SMTP id EE/20-30863-33CE1054; Fri, 08 Sep 2006 18:18:27 -0400\n", + "expected": { + "from_ip": "10.225.209.19", + "by": { + "Name": "ecelerity-va-1" + }, + "with": "SMTP", + "id": "EE", + "date": { + "year": 2006, + "month": 9, + "day": 8, + "hour": 18, + "minute": 18, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from ([127.0.0.1:32923]) by bm1-21.ed10.com (ecelerity 2.1.1ea r(11031M)) with ECSTREAM id 8B/57-16227-3764EB44 for ; Wed, 19 Jul 2006 10:49:23 -0400\n", + "expected": { + "from_ip": "127.0.0.1", + "by": { + "Name": "bm1-21.ed10.com" + }, + "for_": "example@vandinter.org", + "id": "8B", + "date": { + "year": 2006, + "month": 7, + "day": 19, + "hour": 10, + "minute": 49, + "second": 23, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from ([192.168.1.151:49601] helo=dev1.democracyinaction.org) by m12.prod.democracyinaction.com (ecelerity 2.1.1.3 r(11743)) with ESMTP id 52/92-02454-89FBA054 for ; Fri, 15 Sep 2006 10:58:32 -0400\n", + "expected": { + "from_ip": "192.168.1.151", + "by": { + "Name": "m12.prod.democracyinaction.com" + }, + "for_": "example@vandinter.org", + "with": "ESMTP", + "id": "52", + "helo": { + "Name": "dev1.democracyinaction.org" + }, + "helo_cmd": "Helo", + "date": { + "year": 2006, + "month": 9, + "day": 15, + "hour": 10, + "minute": 58, + "second": 32, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from root (helo=candygram.thunk.org) by thunker.thunk.org with local-esmtps (tls_cipher TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.50 #1 (Debian)) id 1FwHqR-0008Bw-OG; Fri, 30 Jun 2006 08:11:35 -0400\n", + "expected": { + "from": { + "Name": "root" + }, + "by": { + "Name": "thunker.thunk.org" + }, + "with": "ESMTPS", + "tls_version": "TLSv1_0", + "tls_cipher": "RSA_AES_256_CBC_SHA", + "id": "1FwHqR-0008Bw-OG", + "helo": { + "Name": "candygram.thunk.org" + }, + "helo_cmd": "Helo", + "date": { + "year": 2006, + "month": 6, + "day": 30, + "hour": 8, + "minute": 11, + "second": 35, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from root (helo=localhost) by broadcast.iac.iafrica.com with local-bsmtp (Exim 4.30; FreeBSD) id 1GN22d-0000xp-2K for example@vandinter.org; Tue, 12 Sep 2006 08:46:43 +0200\n", + "expected": { + "from": { + "Name": "root" + }, + "by": { + "Name": "broadcast.iac.iafrica.com" + }, + "for_": "example@vandinter.org", + "with": "SMTP", + "id": "1GN22d-0000xp-2K", + "helo": { + "Name": "localhost" + }, + "helo_cmd": "Helo", + "date": { + "year": 2006, + "month": 9, + "day": 12, + "hour": 8, + "minute": 46, + "second": 43, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from smarter (helo=localhost) by mx1-out.lists.smarterliving.com with local-bsmtp (Exim 4.24) id 1GIRA2-0007IZ-4n for example@vandinter.org; Wed, 30 Aug 2006 10:35:22 -0400\n", + "expected": { + "from": { + "Name": "smarter" + }, + "by": { + "Name": "mx1-out.lists.smarterliving.com" + }, + "for_": "example@vandinter.org", + "with": "SMTP", + "id": "1GIRA2-0007IZ-4n", + "helo": { + "Name": "localhost" + }, + "helo_cmd": "Helo", + "date": { + "year": 2006, + "month": 8, + "day": 30, + "hour": 10, + "minute": 35, + "second": 22, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from andrew by trinity.supernews.net with local (Exim 4.12) id 18xeL6-000Dn1-00; Tue, 25 Mar 2003 02:39:00 +0000\n", + "expected": { + "from": { + "Name": "andrew" + }, + "by": { + "Name": "trinity.supernews.net" + }, + "with": "Local", + "id": "18xeL6-000Dn1-00", + "date": { + "year": 2003, + "month": 3, + "day": 25, + "hour": 2, + "minute": 39, + "second": 0, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from [61.174.163.26] (helo=host) by sc8-sf-list1.sourceforge.net with smtp (Exim 3.31-VA-mm2 #1 (Debian)) id 18t2z0-0001NX-00 for ; Wed, 12 Mar 2003 01:57:10 -0800\n", + "expected": { + "from": { + "IpAddr": "61.174.163.26" + }, + "by": { + "Name": "sc8-sf-list1.sourceforge.net" + }, + "for_": "razor-users@lists.sourceforge.net", + "with": "SMTP", + "id": "18t2z0-0001NX-00", + "helo": { + "Name": "host" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 3, + "day": 12, + "hour": 1, + "minute": 57, + "second": 10, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from [218.19.142.229] (helo=hotmail.com ident=yiuhyotp) by yzordderrex with smtp (Exim 3.35 #1 (Debian)) id 194BE5-0005Zh-00; Sat, 12 Apr 2003 03:58:53 +0100\n", + "expected": { + "from": { + "IpAddr": "218.19.142.229" + }, + "by": { + "Name": "yzordderrex" + }, + "with": "SMTP", + "id": "194BE5-0005Zh-00", + "ident": "yiuhyotp", + "helo": { + "Name": "hotmail.com" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 4, + "day": 12, + "hour": 3, + "minute": 58, + "second": 53, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from sc8-sf-list1-b.sourceforge.net ([10.3.1.13] helo=sc8-sf-list1.sourceforge.net) by sc8-sf-list2.sourceforge.net with esmtp (Exim 3.31-VA-mm2 #1 (Debian)) id 18t301-0007Bh-00; Wed, 12 Mar 2003 01:58:13 -0800\n", + "expected": { + "from": { + "Name": "sc8-sf-list1-b.sourceforge.net" + }, + "from_ip": "10.3.1.13", + "by": { + "Name": "sc8-sf-list2.sourceforge.net" + }, + "with": "ESMTP", + "id": "18t301-0007Bh-00", + "helo": { + "Name": "sc8-sf-list1.sourceforge.net" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 3, + "day": 12, + "hour": 1, + "minute": 58, + "second": 13, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from dsl092-072-213.bos1.dsl.speakeasy.net ([66.92.72.213] helo=blazing.arsecandle.org) by sc8-sf-list1.sourceforge.net with esmtp (Cipher TLSv1:DES-CBC3-SHA:168) (Exim 3.31-VA-mm2 #1 (Debian)) id 18lyuU-0007TI-00 for ; Thu, 20 Feb 2003 14:11:18 -0800\n", + "expected": { + "from": { + "Name": "dsl092-072-213.bos1.dsl.speakeasy.net" + }, + "from_ip": "66.92.72.213", + "by": { + "Name": "sc8-sf-list1.sourceforge.net" + }, + "for_": "SpamAssassin-talk@lists.sourceforge.net", + "with": "ESMTP", + "tls_version": "TLSv1_0", + "tls_cipher": "DES-CBC3-SHA", + "id": "18lyuU-0007TI-00", + "helo": { + "Name": "blazing.arsecandle.org" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 2, + "day": 20, + "hour": 14, + "minute": 11, + "second": 18, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from eclectic.kluge.net ([66.92.69.221] ident=[W9VcNxE2vKxgWHD05PJbLzIHSxcmZQ/O]) by sc8-sf-list1.sourceforge.net with esmtp (Cipher TLSv1:DES-CBC3-SHA:168) (Exim 3.31-VA-mm2 #1 (Debian)) id 18m0hT-00031I-00 for ; Thu, 20 Feb 2003 16:06:00 -0800\n", + "expected": { + "from": { + "Name": "eclectic.kluge.net" + }, + "from_ip": "66.92.69.221", + "by": { + "Name": "sc8-sf-list1.sourceforge.net" + }, + "for_": "spamassassin-talk@lists.sourceforge.net", + "with": "ESMTP", + "tls_version": "TLSv1_0", + "tls_cipher": "DES-CBC3-SHA", + "id": "18m0hT-00031I-00", + "ident": "W9VcNxE2vKxgWHD05PJbLzIHSxcmZQ", + "date": { + "year": 2003, + "month": 2, + "day": 20, + "hour": 16, + "minute": 6, + "second": 0, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from mail.ssccbelen.edu.pe ([216.244.149.154]) by yzordderrex with esmtp (Exim 3.35 #1 (Debian)) id 18tqiz-000702-00 for ; Fri, 14 Mar 2003 15:03:57 +0000\n", + "expected": { + "from": { + "Name": "mail.ssccbelen.edu.pe" + }, + "from_ip": "216.244.149.154", + "by": { + "Name": "yzordderrex" + }, + "for_": "jm@example.com", + "with": "ESMTP", + "id": "18tqiz-000702-00", + "date": { + "year": 2003, + "month": 3, + "day": 14, + "hour": 15, + "minute": 3, + "second": 57, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from server040.webpack.hosteurope.de ([80.237.130.48]:52313) by vps832469583.serverpool.info with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.50) id 1GzVLs-0002Oz-7b\n", + "expected": { + "from": { + "Name": "server040.webpack.hosteurope.de" + }, + "from_ip": "80.237.130.48", + "by": { + "Name": "vps832469583.serverpool.info" + }, + "with": "ESMTPS", + "tls_version": "TLSv1_0", + "tls_cipher": "DHE_RSA_3DES_EDE_CBC_SHA", + "id": "1GzVLs-0002Oz-7b", + "date": null + } + }, + { + "header": "from boggle.ihug.co.nz [203.109.252.209] by grunt6.ihug.co.nz with esmtp (Exim 3.35 #1 (Debian)) id 18SWRe-0006X6-00; Sun, 29 Dec 2002 18:57:06 +1300\n", + "expected": { + "from": { + "Name": "boggle.ihug.co.nz" + }, + "from_ip": "203.109.252.209", + "by": { + "Name": "grunt6.ihug.co.nz" + }, + "with": "ESMTP", + "id": "18SWRe-0006X6-00", + "date": { + "year": 2002, + "month": 12, + "day": 29, + "hour": 18, + "minute": 57, + "second": 6, + "tz_before_gmt": false, + "tz_hour": 13, + "tz_minute": 0 + } + } + }, + { + "header": "from helene8.i.pinwand.net (helene.cats.ms) [10.0.8.6.13219] (mail) by lisbeth.i.pinwand.net with esmtp (Exim 3.35 #1 (Debian)) id 1CO5y7-0001vC-00; Sun, 31 Oct 2004 04:01:23 +0100\n", + "expected": { + "from": { + "Name": "helene8.i.pinwand.net" + }, + "from_iprev": "helene.cats.ms", + "by": { + "Name": "lisbeth.i.pinwand.net" + }, + "with": "ESMTP", + "id": "1CO5y7-0001vC-00", + "date": { + "year": 2004, + "month": 10, + "day": 31, + "hour": 4, + "minute": 1, + "second": 23, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from localhost (unknown [127.0.0.1]) by cabbage.jmason.org (Postfix) with ESMTP id A96E18BD97 for ; Thu, 13 Mar 2003 15:23:15 -0500 (EST)\n", + "expected": { + "from": { + "Name": "localhost" + }, + "from_ip": "127.0.0.1", + "by": { + "Name": "cabbage.jmason.org" + }, + "for_": "jm@localhost", + "with": "ESMTP", + "id": "A96E18BD97", + "date": { + "year": 2003, + "month": 3, + "day": 13, + "hour": 15, + "minute": 23, + "second": 15, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from 207.8.214.3 (unknown[211.94.164.65]) by puzzle.pobox.com (Postfix) with SMTP id 9029AFB732; Sat, 8 Nov 2003 17:57:46 -0500 (EST)\n", + "expected": { + "from": { + "IpAddr": "207.8.214.3" + }, + "from_ip": "211.94.164.65", + "by": { + "Name": "puzzle.pobox.com" + }, + "with": "SMTP", + "id": "9029AFB732", + "date": { + "year": 2003, + "month": 11, + "day": 8, + "hour": 17, + "minute": 57, + "second": 46, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from DPLAPTOP ( 72.242.176.162) by mail.puryear-it.com (Scalix SMTP Relay 10.0.1.3) via ESMTP; Fri, 23 Jun 2006 16:39:47 -0500 (CDT)\n", + "expected": { + "from": { + "Name": "DPLAPTOP" + }, + "from_ip": "72.242.176.162", + "by": { + "Name": "mail.puryear-it.com" + }, + "via": "ESMTP", + "date": { + "year": 2006, + "month": 6, + "day": 23, + "hour": 16, + "minute": 39, + "second": 47, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from 217.137.58.28 ([217.137.58.28]) by webmail.ukonline.net (IMP) with HTTP for ; Sun, 11 Apr 2004 00:31:07 +0100\n", + "expected": { + "from": { + "IpAddr": "217.137.58.28" + }, + "from_ip": "217.137.58.28", + "by": { + "Name": "webmail.ukonline.net" + }, + "for_": "anarchyintheuk@localhost", + "with": "HTTP", + "date": { + "year": 2004, + "month": 4, + "day": 11, + "hour": 0, + "minute": 31, + "second": 7, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from mail1.insuranceiq.com (host66.insuranceiq.com [65.217.159.66] (may be forged)) by dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id h2F0c2x31856 for ; Sat, 15 Mar 2003 00:38:03 GMT\n", + "expected": { + "from": { + "Name": "mail1.insuranceiq.com" + }, + "from_ip": "65.217.159.66", + "from_iprev": "host66.insuranceiq.com", + "by": { + "Name": "dogma.slashnull.org" + }, + "for_": "jm@jmason.org", + "with": "ESMTP", + "id": "h2F0c2x31856", + "date": { + "year": 2003, + "month": 3, + "day": 15, + "hour": 0, + "minute": 38, + "second": 3, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from BAY0-HMR08.adinternal.hotmail.com (bay0-hmr08.bay0.hotmail.com [65.54.241.207]) by dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id h2DBpvs24047 for ; Thu, 13 Mar 2003 11:51:57 GMT\n", + "expected": { + "from": { + "Name": "BAY0-HMR08.adinternal.hotmail.com" + }, + "from_ip": "65.54.241.207", + "from_iprev": "bay0-hmr08.bay0.hotmail.com", + "by": { + "Name": "dogma.slashnull.org" + }, + "for_": "webmaster@efi.ie", + "with": "ESMTP", + "id": "h2DBpvs24047", + "date": { + "year": 2003, + "month": 3, + "day": 13, + "hour": 11, + "minute": 51, + "second": 57, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from ran-out.mx.develooper.com (IDENT:qmailr@one.develooper.com [64.81.84.115]) by dogma.slashnull.org (8.11.6/8.11.6) with SMTP id h381Vvf19860 for ; Tue, 8 Apr 2003 02:31:57 +0100\n", + "expected": { + "from": { + "Name": "ran-out.mx.develooper.com" + }, + "from_ip": "64.81.84.115", + "by": { + "Name": "dogma.slashnull.org" + }, + "for_": "jm-cpan@jmason.org", + "with": "SMTP", + "id": "h381Vvf19860", + "ident": "qmailr@one.develooper.com", + "date": { + "year": 2003, + "month": 4, + "day": 8, + "hour": 2, + "minute": 31, + "second": 57, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from rev.net (natpool62.rev.net [63.148.93.62] (may be forged)) (authenticated) by mail.rev.net (8.11.4/8.11.4) with ESMTP id h0KKa7d32306 for \n", + "expected": { + "from": { + "Name": "rev.net" + }, + "from_ip": "63.148.93.62", + "from_iprev": "natpool62.rev.net", + "by": { + "Name": "mail.rev.net" + }, + "for_": "spamassassin-talk@lists.sourceforge.net", + "with": "ESMTP", + "id": "h0KKa7d32306", + "date": null + } + }, + { + "header": "from ns.elcanto.co.kr (66.161.246.58 [66.161.246.58]) by mail.ssccbelen.edu.pe with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.1960.3) id G69TW478; Thu, 13 Mar 2003 14:01:10 -0500\n", + "expected": { + "from": { + "Name": "ns.elcanto.co.kr" + }, + "from_ip": "66.161.246.58", + "by": { + "Name": "mail.ssccbelen.edu.pe" + }, + "with": "SMTP", + "id": "G69TW478", + "date": { + "year": 2003, + "month": 3, + "day": 13, + "hour": 14, + "minute": 1, + "second": 10, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from mail2.detr.gsi.gov.uk ([51.64.35.18] helo=ahvfw.dtlr.gsi.gov.uk) by mail4.gsi.gov.uk with smtp id 190K1R-0000me-00 for spamassassin-talk-admin@lists.sourceforge.net; Tue, 01 Apr 2003 12:33:46 +0100\n", + "expected": { + "from": { + "Name": "mail2.detr.gsi.gov.uk" + }, + "from_ip": "51.64.35.18", + "by": { + "Name": "mail4.gsi.gov.uk" + }, + "for_": "spamassassin-talk-admin@lists.sourceforge.net", + "with": "SMTP", + "id": "190K1R-0000me-00", + "helo": { + "Name": "ahvfw.dtlr.gsi.gov.uk" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 4, + "day": 1, + "hour": 12, + "minute": 33, + "second": 46, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from 12-211-5-69.client.attbi.com ([12.211.5.69]) by rwcrmhc53.attbi.com (rwcrmhc53) with SMTP id <2002112823351305300akl1ue>; Thu, 28 Nov 2002 23:35:13 +0000\n", + "expected": { + "from": { + "Name": "12-211-5-69.client.attbi.com" + }, + "from_ip": "12.211.5.69", + "from_iprev": "unknown.domain", + "by": { + "Name": "rwcrmhc53.attbi.com" + }, + "with": "SMTP", + "id": "2002112823351305300akl1ue", + "date": { + "year": 2002, + "month": 11, + "day": 28, + "hour": 23, + "minute": 35, + "second": 13, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from attbi.com (h000502e08144.ne.client2.attbi.com[24.128.27.103]) by rwcrmhc53.attbi.com (rwcrmhc53) with SMTP id <20030222193438053008f7tee>; Sat, 22 Feb 2003 19:34:39 +0000\n", + "expected": { + "from": { + "Name": "attbi.com" + }, + "from_ip": "24.128.27.103", + "from_iprev": "h000502e08144.ne.client2.attbi.com", + "by": { + "Name": "rwcrmhc53.attbi.com" + }, + "with": "SMTP", + "id": "20030222193438053008f7tee", + "date": { + "year": 2003, + "month": 2, + "day": 22, + "hour": 19, + "minute": 34, + "second": 39, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from 4wtgRl (kgbxn@[211.244.147.115]) by dogma.slashnull.org (8.11.6/8.11.6) with SMTP id h8BBsUJ18848; Thu, 11 Sep 2003 12:54:31 +0100\n", + "expected": { + "from": { + "Name": "4wtgRl" + }, + "from_ip": "211.244.147.115", + "by": { + "Name": "dogma.slashnull.org" + }, + "with": "SMTP", + "id": "h8BBsUJ18848", + "ident": "kgbxn", + "date": { + "year": 2003, + "month": 9, + "day": 11, + "hour": 12, + "minute": 54, + "second": 31, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from 213.123.174.21 by lw11fd.law11.hotmail.msn.com with HTTP; Wed, 24 Jul 2002 16:36:44 GMT\n", + "expected": { + "from": { + "IpAddr": "213.123.174.21" + }, + "by": { + "Name": "lw11fd.law11.hotmail.msn.com" + }, + "with": "HTTP", + "date": { + "year": 2002, + "month": 7, + "day": 24, + "hour": 16, + "minute": 36, + "second": 44, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from x71-x56-x24-5.webspeed.dk (HELO niels) (69.96.3.15) by la.mx.develooper.com (qpsmtpd/0.27-dev) with SMTP; Fri, 02 Jan 2004 19:26:52 -0800\n", + "expected": { + "from": { + "Name": "x71-x56-x24-5.webspeed.dk" + }, + "from_ip": "69.96.3.15", + "by": { + "Name": "la.mx.develooper.com" + }, + "with": "SMTP", + "helo": { + "Name": "niels" + }, + "helo_cmd": "Helo", + "date": { + "year": 2004, + "month": 1, + "day": 2, + "hour": 19, + "minute": 26, + "second": 52, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from sc8-sf-sshgate.sourceforge.net (HELO sc8-sf-netmisc.sourceforge.net) (66.35.250.220) by la.mx.develooper.com (qpsmtpd/0.27-dev) with ESMTP; Fri, 02 Jan 2004 14:44:41 -0800\n", + "expected": { + "from": { + "Name": "sc8-sf-sshgate.sourceforge.net" + }, + "from_ip": "66.35.250.220", + "by": { + "Name": "la.mx.develooper.com" + }, + "with": "ESMTP", + "helo": { + "Name": "sc8-sf-netmisc.sourceforge.net" + }, + "helo_cmd": "Helo", + "date": { + "year": 2004, + "month": 1, + "day": 2, + "hour": 14, + "minute": 44, + "second": 41, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from mx10.topofferz.net (HELO ) (69.6.60.10) by blazing.arsecandle.org with SMTP; 3 Mar 2004 20:34:38 -0000\n", + "expected": { + "from": { + "Name": "mx10.topofferz.net" + }, + "from_ip": "69.6.60.10", + "by": { + "Name": "blazing.arsecandle.org" + }, + "with": "SMTP", + "helo_cmd": "Helo", + "date": { + "year": 2004, + "month": 3, + "day": 3, + "hour": 20, + "minute": 34, + "second": 38, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from mail-backend.DDDD.com (LHLO mail-backend.DDDD.com) (10.2.2.20) by mail-backend.DDDD.com with LMTP; Thu, 18 Jun 2015 16:50:56 -0700 (PDT)\n", + "expected": { + "from": { + "Name": "mail-backend.DDDD.com" + }, + "from_ip": "10.2.2.20", + "by": { + "Name": "mail-backend.DDDD.com" + }, + "with": "LMTP", + "helo": { + "Name": "mail-backend.DDDD.com" + }, + "helo_cmd": "Lhlo", + "date": { + "year": 2015, + "month": 6, + "day": 18, + "hour": 16, + "minute": 50, + "second": 56, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from dslb-082-083-045-064.pools.arcor-ip.net (EHLO homepc) [82.83.45.64] by mail.gmx.net (mp010) with SMTP; 03 Feb 2007 13:13:47 +0100\n", + "expected": { + "from": { + "Name": "dslb-082-083-045-064.pools.arcor-ip.net" + }, + "from_ip": "82.83.45.64", + "by": { + "Name": "mail.gmx.net" + }, + "with": "SMTP", + "helo": { + "Name": "homepc" + }, + "helo_cmd": "Ehlo", + "date": { + "year": 2007, + "month": 2, + "day": 3, + "hour": 13, + "minute": 13, + "second": 47, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from imo-m01.mx.aol.com ([64.12.136.4]) by eagle.glenraven.com via smtpd (for [198.85.87.98]) with SMTP; Wed, 08 Oct 2003 16:25:37 -0400\n", + "expected": { + "from": { + "Name": "imo-m01.mx.aol.com" + }, + "from_ip": "64.12.136.4", + "by": { + "Name": "eagle.glenraven.com" + }, + "with": "SMTP", + "via": "smtpd", + "date": { + "year": 2003, + "month": 10, + "day": 8, + "hour": 16, + "minute": 25, + "second": 37, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from postfix3-2.free.fr (HELO machine.domain.com) (foobar@213.228.0.169) by totor.bouissou.net with SMTP; 14 Nov 2003 08:05:50 -0000\n", + "expected": { + "from": { + "Name": "postfix3-2.free.fr" + }, + "by": { + "Name": "totor.bouissou.net" + }, + "with": "SMTP", + "ident": "foobar@213.228.0.169", + "helo": { + "Name": "machine.domain.com" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 11, + "day": 14, + "hour": 8, + "minute": 5, + "second": 50, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from unknown (HELO terpsichore.farfalle.com) (jdavid@[216.254.40.70]) (envelope-sender ) by mail13.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 12 Feb 2003 18:23:19 -0000\n", + "expected": { + "from": { + "Name": "unknown" + }, + "from_ip": "216.254.40.70", + "by": { + "Name": "mail13.speakeasy.net" + }, + "for_": "jm@jmason.org", + "with": "SMTP", + "ident": "jdavid@farfalle.com", + "helo": { + "Name": "terpsichore.farfalle.com" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 2, + "day": 12, + "hour": 18, + "minute": 23, + "second": 19, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from 211.245.85.228 (EHLO ) (211.245.85.228) by mta232.mail.scd.yahoo.com with SMTP; Sun, 25 Jan 2004 00:24:37 -0800\n", + "expected": { + "from": { + "IpAddr": "211.245.85.228" + }, + "from_ip": "211.245.85.228", + "by": { + "Name": "mta232.mail.scd.yahoo.com" + }, + "with": "SMTP", + "helo_cmd": "Ehlo", + "date": { + "year": 2004, + "month": 1, + "day": 25, + "hour": 0, + "minute": 24, + "second": 37, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from [193.220.176.134] by web40310.mail.yahoo.com via HTTP; Wed, 12 Feb 2003 14:22:21 PST\n", + "expected": { + "from": { + "IpAddr": "193.220.176.134" + }, + "by": { + "Name": "web40310.mail.yahoo.com" + }, + "via": "HTTP", + "date": { + "year": 2003, + "month": 2, + "day": 12, + "hour": 14, + "minute": 22, + "second": 21, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from 192.168.5.158 ( [192.168.5.158]) as user jason@localhost by mail.reusch.net with HTTP; Mon, 8 Jul 2002 23:24:56 -0400\n", + "expected": { + "from": { + "IpAddr": "192.168.5.158" + }, + "from_ip": "192.168.5.158", + "by": { + "Name": "mail.reusch.net" + }, + "with": "HTTP", + "ident": "jason@localhost", + "date": { + "year": 2002, + "month": 7, + "day": 8, + "hour": 23, + "minute": 24, + "second": 56, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from (64.52.135.194 [64.52.135.194]) by mail.unearthed.com with ESMTP id BQB0hUH2 Thu, 20 Feb 2003 16:13:20 -0700 (PST)\n", + "expected": { + "from_ip": "64.52.135.194", + "by": { + "Name": "mail.unearthed.com" + }, + "with": "ESMTP", + "id": "BQB0hUH2", + "date": null + } + }, + { + "header": "from [65.167.180.251] by relent.cedata.com (MessageWall 1.1.0) with SMTP; 20 Feb 2003 23:57:15 -0000\n", + "expected": { + "from": { + "IpAddr": "65.167.180.251" + }, + "by": { + "Name": "relent.cedata.com" + }, + "with": "SMTP", + "date": { + "year": 2003, + "month": 2, + "day": 20, + "hour": 23, + "minute": 57, + "second": 15, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from ([172.16.1.78]) by email2.codeworksonline.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 6 Sep 2006 21:14:29 -0400\n", + "expected": { + "from_ip": "172.16.1.78", + "by": { + "Name": "email2.codeworksonline.com" + }, + "with": "SMTP", + "date": { + "year": 2006, + "month": 9, + "day": 6, + "hour": 21, + "minute": 14, + "second": 29, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from (130.215.36.186) by mcafee.wpi.edu via smtp id 021b_7e19a55a_ea7e_11da_83a9_00304811e63a; Tue, 23 May 2006 13:06:35 -0400\n", + "expected": { + "from_ip": "130.215.36.186", + "by": { + "Name": "mcafee.wpi.edu" + }, + "id": "021b_7e19a55a_ea7e_11da_83a9_00304811e63a", + "via": "smtp", + "date": { + "year": 2006, + "month": 5, + "day": 23, + "hour": 13, + "minute": 6, + "second": 35, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from ([172.21.2.10]) by out-relay4.mtahq.org with ESMTP id 4420961.8281; Tue, 22 Aug 2006 17:53:08 -0400\n", + "expected": { + "from_ip": "172.21.2.10", + "by": { + "Name": "out-relay4.mtahq.org" + }, + "with": "ESMTP", + "id": "4420961.8281", + "date": { + "year": 2006, + "month": 8, + "day": 22, + "hour": 17, + "minute": 53, + "second": 8, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from acecomms [202.83.84.95] by mailscan.acenet.net.au [202.83.84.27] with SMTP (MDaemon.PRO.v5.0.6.R) for ; Fri, 21 Feb 2003 09:32:27 +1000\n", + "expected": { + "from": { + "Name": "acecomms" + }, + "from_ip": "202.83.84.95", + "by": { + "Name": "mailscan.acenet.net.au" + }, + "for_": "spamassassin-talk@lists.sourceforge.net", + "with": "SMTP", + "date": { + "year": 2003, + "month": 2, + "day": 21, + "hour": 9, + "minute": 32, + "second": 27, + "tz_before_gmt": false, + "tz_hour": 10, + "tz_minute": 0 + } + } + }, + { + "header": "from smtp510.aspkunden.de [(134.97.4.21)] by mail.aspemail.de (134.97.4.24) (MDaemon PRO v19.0.2) with ESMTP id md50018233933.msg; Tue, 16 Jul 2019 11:39:22 +0200\n", + "expected": { + "from": { + "Name": "smtp510.aspkunden.de" + }, + "from_ip": "134.97.4.21", + "by": { + "Name": "mail.aspemail.de" + }, + "with": "ESMTP", + "id": "md50018233933.msg", + "date": { + "year": 2019, + "month": 7, + "day": 16, + "hour": 11, + "minute": 39, + "second": 22, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from mail.sxptt.zj.cn ([218.0.185.24]) by dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id h2FH0Zx11330 for ; Sat, 15 Mar 2003 17:00:41 GMT\n", + "expected": { + "from": { + "Name": "mail.sxptt.zj.cn" + }, + "from_ip": "218.0.185.24", + "by": { + "Name": "dogma.slashnull.org" + }, + "for_": "webmaster@efi.ie", + "with": "ESMTP", + "id": "h2FH0Zx11330", + "date": { + "year": 2003, + "month": 3, + "day": 15, + "hour": 17, + "minute": 0, + "second": 41, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from umr-mail7.umr.edu (umr-mail7.umr.edu [131.151.1.64]) via ESMTP by mrelay1.cc.umr.edu (8.12.1/) id h06GHYLZ022481; Mon, 6 Jan 2003 10:17:34 -0600\n", + "expected": { + "from": { + "Name": "umr-mail7.umr.edu" + }, + "from_ip": "131.151.1.64", + "from_iprev": "umr-mail7.umr.edu", + "by": { + "Name": "mrelay1.cc.umr.edu" + }, + "id": "h06GHYLZ022481", + "via": "ESMTP", + "date": { + "year": 2003, + "month": 1, + "day": 6, + "hour": 10, + "minute": 17, + "second": 34, + "tz_before_gmt": true, + "tz_hour": 6, + "tz_minute": 0 + } + } + }, + { + "header": "from Agni (localhost [::ffff:127.0.0.1]) (TLS: TLSv1/SSLv3, 168bits,DES-CBC3-SHA) by agni.forevermore.net with esmtp; Mon, 28 Oct 2002 14:48:52 -0800\n", + "expected": { + "from": { + "Name": "Agni" + }, + "from_ip": "::ffff:127.0.0.1", + "by": { + "Name": "agni.forevermore.net" + }, + "with": "ESMTP", + "tls_version": "TLSv1_0", + "tls_cipher": "DES-CBC3-SHA", + "date": { + "year": 2002, + "month": 10, + "day": 28, + "hour": 14, + "minute": 48, + "second": 52, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from gandalf ([4.37.75.131]) (authenticated bits=0) by herald.cc.purdue.edu (8.12.5/8.12.5/herald) with ESMTP id g9JLefrm028228 for ; Sat, 19 Oct 2002 16:40:41 -0500 (EST)\n", + "expected": { + "from": { + "Name": "gandalf" + }, + "from_ip": "4.37.75.131", + "by": { + "Name": "herald.cc.purdue.edu" + }, + "for_": "spamassassin-talk@lists.sourceforge.net", + "with": "ESMTP", + "id": "g9JLefrm028228", + "date": { + "year": 2002, + "month": 10, + "day": 19, + "hour": 16, + "minute": 40, + "second": 41, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from bushinternet.com (softdnserr [::ffff:61.99.99.67]) by mail.cs.helsinki.fi with esmtp; Fri, 22 Aug 2003 12:25:41 +0300\n", + "expected": { + "from": { + "Name": "bushinternet.com" + }, + "from_ip": "::ffff:61.99.99.67", + "by": { + "Name": "mail.cs.helsinki.fi" + }, + "with": "ESMTP", + "date": { + "year": 2003, + "month": 8, + "day": 22, + "hour": 12, + "minute": 25, + "second": 41, + "tz_before_gmt": false, + "tz_hour": 3, + "tz_minute": 0 + } + } + }, + { + "header": "from jsoliday.acs.internap.com ([63.251.66.24.63559]) by mailhost.acs.internap.com with esmtp (v3.35.1) id 1GNrLz-000295-00; Thu, 14 Sep 2006 09:34:07 -0400\n", + "expected": { + "from": { + "Name": "jsoliday.acs.internap.com" + }, + "by": { + "Name": "mailhost.acs.internap.com" + }, + "with": "ESMTP", + "id": "1GNrLz-000295-00", + "date": { + "year": 2006, + "month": 9, + "day": 14, + "hour": 9, + "minute": 34, + "second": 7, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from roissy (p573.as1.exs.dublin.eircom.net [159.134.226.61]) (authenticated bits=0) by slate.dublin.wbtsystems.com (8.12.6/8.12.6) with ESMTP id g9MFWcvb068860 for ; Tue, 22 Oct 2002 16:32:39 +0100 (IST)\n", + "expected": { + "from": { + "Name": "roissy" + }, + "from_ip": "159.134.226.61", + "from_iprev": "p573.as1.exs.dublin.eircom.net", + "by": { + "Name": "slate.dublin.wbtsystems.com" + }, + "for_": "jm@jmason.org", + "with": "ESMTP", + "id": "g9MFWcvb068860", + "date": { + "year": 2002, + "month": 10, + "day": 22, + "hour": 16, + "minute": 32, + "second": 39, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from cabbage.jmason.org [127.0.0.1] by localhost with IMAP (fetchmail-5.9.0) for jm@localhost (single-drop); Thu, 13 Mar 2003 20:39:56 -0800 (PST)\n", + "expected": { + "from": { + "Name": "cabbage.jmason.org" + }, + "from_ip": "127.0.0.1", + "by": { + "Name": "localhost" + }, + "for_": "jm@localhost", + "with": "IMAP", + "date": { + "year": 2003, + "month": 3, + "day": 13, + "hour": 20, + "minute": 39, + "second": 56, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from pop3.mail.dk (195.41.46.251) by loki.valhalla with POP3; 14 Apr 2010 11:14:29 -0000\n", + "expected": { + "from": { + "Name": "pop3.mail.dk" + }, + "from_ip": "195.41.46.251", + "by": { + "Name": "loki.valhalla" + }, + "with": "POP3", + "date": { + "year": 2010, + "month": 4, + "day": 14, + "hour": 11, + "minute": 14, + "second": 29, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from unknown (HELO feux01a-isp) (213.199.4.210) by totor.bouissou.net with SMTP; 1 Nov 2003 07:05:19 -0000 \n", + "expected": { + "from": { + "Name": "unknown" + }, + "from_ip": "213.199.4.210", + "by": { + "Name": "totor.bouissou.net" + }, + "with": "SMTP", + "helo": { + "Name": "feux01a-isp" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 11, + "day": 1, + "hour": 7, + "minute": 5, + "second": 19, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from adsl-207-213-27-129.dsl.lsan03.pacbell.net (HELO merlin.net.au) (Owner50@207.213.27.129) by totor.bouissou.net with SMTP; 10 Nov 2003 06:30:34 -0000 \n", + "expected": { + "from": { + "Name": "adsl-207-213-27-129.dsl.lsan03.pacbell.net" + }, + "by": { + "Name": "totor.bouissou.net" + }, + "with": "SMTP", + "ident": "Owner50@207.213.27.129", + "helo": { + "Name": "merlin.net.au" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 11, + "day": 10, + "hour": 6, + "minute": 30, + "second": 34, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from x1-6-00-04-bd-d2-e0-a3.k317.webspeed.dk (benelli@80.167.158.170) by totor.bouissou.net with SMTP; 5 Nov 2003 23:18:42 -0000\n", + "expected": { + "from": { + "Name": "x1-6-00-04-bd-d2-e0-a3.k317.webspeed.dk" + }, + "by": { + "Name": "totor.bouissou.net" + }, + "with": "SMTP", + "ident": "benelli@80.167.158.170", + "date": { + "year": 2003, + "month": 11, + "day": 5, + "hour": 23, + "minute": 18, + "second": 42, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from [129.24.215.125] by ws1-7.us4.outblaze.com with http for _bushisevil_@mail.com; Thu, 13 Feb 2003 15:59:28 -0500\n", + "expected": { + "from": { + "IpAddr": "129.24.215.125" + }, + "by": { + "Name": "ws1-7.us4.outblaze.com" + }, + "for_": "_bushisevil_@mail.com", + "with": "HTTP", + "date": { + "year": 2003, + "month": 2, + "day": 13, + "hour": 15, + "minute": 59, + "second": 28, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from snake.corp.yahoo.com(216.145.52.229) by x.x.org via smap (V1.3) id xma093673; Wed, 26 Mar 03 20:43:24 -0600\n", + "expected": { + "from": { + "Name": "snake.corp.yahoo.com" + }, + "from_ip": "216.145.52.229", + "by": { + "Name": "x.x.org" + }, + "id": "xma093673", + "via": "smap", + "date": { + "year": 1903, + "month": 3, + "day": 26, + "hour": 20, + "minute": 43, + "second": 24, + "tz_before_gmt": true, + "tz_hour": 6, + "tz_minute": 0 + } + } + }, + { + "header": "from smtp.greyware.com(208.14.208.51, HELO smtp.sff.net) by x.x.org via smap (V1.3) id xma002908; Fri, 27 Feb 04 14:16:56 -0800\n", + "expected": { + "from": { + "Name": "smtp.greyware.com" + }, + "from_ip": "208.14.208.51", + "by": { + "Name": "x.x.org" + }, + "id": "xma002908", + "helo": { + "Name": "smtp.sff.net" + }, + "helo_cmd": "Helo", + "via": "smap", + "date": { + "year": 1904, + "month": 2, + "day": 27, + "hour": 14, + "minute": 16, + "second": 56, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from [192.168.0.71] by web01-nyc.clicvu.com (Post.Office MTA v3.5.3 release 223 ID# 0-64039U1000L100S0V35) with SMTP id com for ; Tue, 25 Mar 2003 11:42:04 -0500\n", + "expected": { + "from": { + "IpAddr": "192.168.0.71" + }, + "by": { + "Name": "web01-nyc.clicvu.com" + }, + "for_": "x@x.org", + "with": "SMTP", + "id": "com", + "date": { + "year": 2003, + "month": 3, + "day": 25, + "hour": 11, + "minute": 42, + "second": 4, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from [127.0.0.1] by euphoria (ArGoSoft Mail Server Freeware, Version 1.8 (1.8.2.5)); Sat, 8 Feb 2003 09:45:32 +0200\n", + "expected": { + "from": { + "IpAddr": "127.0.0.1" + }, + "by": { + "Name": "euphoria" + }, + "date": { + "year": 2003, + "month": 2, + "day": 8, + "hour": 9, + "minute": 45, + "second": 32, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from 157.54.8.23 by inet-vrs-05.redmond.corp.microsoft.com (InterScan E-Mail VirusWall NT); Thu, 06 Mar 2003 12:02:35 -0800\n", + "expected": { + "from": { + "IpAddr": "157.54.8.23" + }, + "by": { + "Name": "inet-vrs-05.redmond.corp.microsoft.com" + }, + "date": { + "year": 2003, + "month": 3, + "day": 6, + "hour": 12, + "minute": 2, + "second": 35, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from 10.165.130.62 by CNNIMAIL12.CNN.COM (SMTPL release 1.0d) with TCP; Fri, 1 Sep 2006 20:28:14 -0400\n", + "expected": { + "from": { + "IpAddr": "10.165.130.62" + }, + "by": { + "Name": "CNNIMAIL12.CNN.COM" + }, + "date": { + "year": 2006, + "month": 9, + "day": 1, + "hour": 20, + "minute": 28, + "second": 14, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from faerber.muc.de by slarti.muc.de with BSMTP (rsmtp-qm-ot 0.4) for asrg@ietf.org; 7 Mar 2003 21:10:38 -0000\n", + "expected": { + "from": { + "Name": "faerber.muc.de" + }, + "by": { + "Name": "slarti.muc.de" + }, + "for_": "asrg@ietf.org", + "with": "SMTP", + "date": { + "year": 2003, + "month": 3, + "day": 7, + "hour": 21, + "minute": 10, + "second": 38, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from spike (spike.ig.co.uk [193.32.60.32]) by mail.ig.co.uk with SMTP id h27CrCD03362 for ; Fri, 7 Mar 2003 12:53:12 GMT\n", + "expected": { + "from": { + "Name": "spike" + }, + "from_ip": "193.32.60.32", + "from_iprev": "spike.ig.co.uk", + "by": { + "Name": "mail.ig.co.uk" + }, + "for_": "asrg@ietf.org", + "with": "SMTP", + "id": "h27CrCD03362", + "date": { + "year": 2003, + "month": 3, + "day": 7, + "hour": 12, + "minute": 53, + "second": 12, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from customer254-217.iplannetworks.net (HELO AGAMENON) (baldusi@200.69.254.217 with plain) by smtp.mail.vip.sc5.yahoo.com with SMTP; 11 Mar 2003 21:03:28 -0000\n", + "expected": { + "from": { + "Name": "customer254-217.iplannetworks.net" + }, + "by": { + "Name": "smtp.mail.vip.sc5.yahoo.com" + }, + "with": "SMTP", + "ident": "baldusi@200.69.254.217", + "helo": { + "Name": "AGAMENON" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 3, + "day": 11, + "hour": 21, + "minute": 3, + "second": 28, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from [192.168.1.104] (account nazgul HELO [192.168.1.104]) by somewhere.com (CommuniGate Pro SMTP 3.5.7) with ESMTP-TLS id 2088434; Fri, 07 Mar 2003 13:05:06 -0500\n", + "expected": { + "from": { + "IpAddr": "192.168.1.104" + }, + "by": { + "Name": "somewhere.com" + }, + "with": "ESMTPS", + "id": "2088434", + "helo": { + "IpAddr": "192.168.1.104" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 3, + "day": 7, + "hour": 13, + "minute": 5, + "second": 6, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from host.example.com ([192.0.2.1] verified) by mail.example.net (CommuniGate Pro SMTP 5.1.13) with ESMTP id 9786656 for user@example.net; Thu, 27 Mar 2008 15:08:17 +0600\n", + "expected": { + "from": { + "Name": "host.example.com" + }, + "from_ip": "192.0.2.1", + "by": { + "Name": "mail.example.net" + }, + "for_": "user@example.net", + "with": "ESMTP", + "id": "9786656", + "date": { + "year": 2008, + "month": 3, + "day": 27, + "hour": 15, + "minute": 8, + "second": 17, + "tz_before_gmt": false, + "tz_hour": 6, + "tz_minute": 0 + } + } + }, + { + "header": "from ([10.0.0.6]) by mail0.ciphertrust.com with ESMTP ; Thu, 13 Mar 2003 06:26:21 -0500 (EST)\n", + "expected": { + "from_ip": "10.0.0.6", + "by": { + "Name": "mail0.ciphertrust.com" + }, + "with": "ESMTP", + "date": { + "year": 2003, + "month": 3, + "day": 13, + "hour": 6, + "minute": 26, + "second": 21, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from ironport.com (10.1.1.5) by a50.ironport.com with ESMTP; 01 Apr 2003 12:00:51 -0800\n", + "expected": { + "from": { + "Name": "ironport.com" + }, + "from_ip": "10.1.1.5", + "by": { + "Name": "a50.ironport.com" + }, + "with": "ESMTP", + "date": { + "year": 2003, + "month": 4, + "day": 1, + "hour": 12, + "minute": 0, + "second": 51, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from dyn-81-166-39-132.ppp.tiscali.fr (81.166.39.132) by cpmail.dk.tiscali.com (6.7.018)\n", + "expected": { + "from": { + "Name": "dyn-81-166-39-132.ppp.tiscali.fr" + }, + "from_ip": "81.166.39.132", + "by": { + "Name": "cpmail.dk.tiscali.com" + }, + "date": null + } + }, + { + "header": "from scv3.apple.com (scv3.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Mon, 17 Mar 2003 17:04:54 -0800\n", + "expected": { + "from": { + "Name": "scv3.apple.com" + }, + "from_iprev": "scv3.apple.com", + "by": { + "Name": "mailgate2.apple.com" + }, + "with": "ESMTP", + "id": "T61095998e1118164e13f8@mailgate2.apple.com", + "date": { + "year": 2003, + "month": 3, + "day": 17, + "hour": 17, + "minute": 4, + "second": 54, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from 01al10015010057.ad.bls.com ([90.152.5.141] [90.152.5.141]) by aismtp3g.bls.com with ESMTP; Mon, 10 Mar 2003 11:10:41 -0500\n", + "expected": { + "from": { + "Name": "01al10015010057.ad.bls.com" + }, + "from_ip": "90.152.5.141", + "by": { + "Name": "aismtp3g.bls.com" + }, + "with": "ESMTP", + "date": { + "year": 2003, + "month": 3, + "day": 10, + "hour": 11, + "minute": 10, + "second": 41, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from 206.47.0.153 by dm3cn8.bell.ca with ESMTP (Tumbleweed MMS SMTP Relay (MMS v5.0)); Mon, 24 Mar 2003 19:49:48 -0500\n", + "expected": { + "from": { + "IpAddr": "206.47.0.153" + }, + "by": { + "Name": "dm3cn8.bell.ca" + }, + "with": "ESMTP", + "date": { + "year": 2003, + "month": 3, + "day": 24, + "hour": 19, + "minute": 49, + "second": 48, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from pobox.com (h005018086b3b.ne.client2.attbi.com[66.31.45.164]) by rwcrmhc53.attbi.com (rwcrmhc53) with SMTP id <2003031302165605300suph7e>; Thu, 13 Mar 2003 02:16:56 +0000\n", + "expected": { + "from": { + "Name": "pobox.com" + }, + "from_ip": "66.31.45.164", + "from_iprev": "h005018086b3b.ne.client2.attbi.com", + "by": { + "Name": "rwcrmhc53.attbi.com" + }, + "with": "SMTP", + "id": "2003031302165605300suph7e", + "date": { + "year": 2003, + "month": 3, + "day": 13, + "hour": 2, + "minute": 16, + "second": 56, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from [10.128.128.81]:50999 (HELO dfintra.f-secure.com) by fsav4im2 ([10.128.128.74]:25) (F-Secure Anti-Virus for Internet Mail 6.0.34 Release) with SMTP; Tue, 5 Mar 2002 14:11:53 -0000\n", + "expected": { + "from": { + "IpAddr": "10.128.128.81" + }, + "by": { + "Name": "fsav4im2" + }, + "with": "SMTP", + "helo": { + "Name": "dfintra.f-secure.com" + }, + "helo_cmd": "Helo", + "date": { + "year": 2002, + "month": 3, + "day": 5, + "hour": 14, + "minute": 11, + "second": 53, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from 62.180.7.250 (HELO daisy) by smtp.altavista.de (209.228.22.152) with SMTP; 19 Sep 2002 17:03:17 +0000\n", + "expected": { + "from": { + "IpAddr": "62.180.7.250" + }, + "by": { + "Name": "smtp.altavista.de" + }, + "with": "SMTP", + "helo": { + "Name": "daisy" + }, + "helo_cmd": "Helo", + "date": { + "year": 2002, + "month": 9, + "day": 19, + "hour": 17, + "minute": 3, + "second": 17, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from oemcomputer [63.232.189.195] by highstream.net (SMTPD32-7.07) id A4CE7F2A0028; Sat, 01 Feb 2003 21:39:10 -0500\n", + "expected": { + "from": { + "Name": "oemcomputer" + }, + "from_ip": "63.232.189.195", + "by": { + "Name": "highstream.net" + }, + "id": "A4CE7F2A0028", + "date": { + "year": 2003, + "month": 2, + "day": 1, + "hour": 21, + "minute": 39, + "second": 10, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from nodnsquery(192.100.64.12) by herbivore.monmouth.edu via csmap (V4.1) id srcAAAyHaywy\n", + "expected": { + "from": { + "Name": "nodnsquery" + }, + "from_ip": "192.100.64.12", + "by": { + "Name": "herbivore.monmouth.edu" + }, + "id": "srcAAAyHaywy", + "via": "csmap", + "date": null + } + }, + { + "header": "from [192.168.0.13] by (MailGate 3.5.172) with SMTP; Tue, 1 Apr 2003 15:04:55 +0100\n", + "expected": { + "from": { + "IpAddr": "192.168.0.13" + }, + "by": { + "Name": "server" + }, + "with": "SMTP", + "date": { + "year": 2003, + "month": 4, + "day": 1, + "hour": 15, + "minute": 4, + "second": 55, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from jmason.org (unverified [195.218.107.131]) by ni-mail1.dna.utvinternet.net ; Tue, 11 Feb 2003 12:18:12 +0000\n", + "expected": { + "from": { + "Name": "jmason.org" + }, + "from_ip": "195.218.107.131", + "by": { + "Name": "ni-mail1.dna.utvinternet.net" + }, + "date": { + "year": 2003, + "month": 2, + "day": 11, + "hour": 12, + "minute": 18, + "second": 12, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from [212.87.144.30] (account seiz [212.87.144.30] verified) by x.imd.net (CommuniGate Pro SMTP 4.0.3) with ESMTP-TLS id 5026665 for spamassassin-talk@lists.sourceforge.net; Wed, 15 Jan 2003 16:27:05 +0100\n", + "expected": { + "from": { + "IpAddr": "212.87.144.30" + }, + "from_ip": "212.87.144.30", + "by": { + "Name": "x.imd.net" + }, + "for_": "spamassassin-talk@lists.sourceforge.net", + "with": "ESMTPS", + "id": "5026665", + "date": { + "year": 2003, + "month": 1, + "day": 15, + "hour": 16, + "minute": 27, + "second": 5, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from [206.51.230.145] (helo=t-online.de) by mxeu2.kundenserver.de with ESMTP (Nemesis), id 0MKpdM-1CkRpr14PF-000608; Fri, 31 Dec 2004 19:49:15 +0100\n", + "expected": { + "from": { + "IpAddr": "206.51.230.145" + }, + "by": { + "Name": "mxeu2.kundenserver.de" + }, + "with": "ESMTP", + "id": "0MKpdM-1CkRpr14PF-000608", + "helo": { + "Name": "t-online.de" + }, + "helo_cmd": "Helo", + "date": { + "year": 2004, + "month": 12, + "day": 31, + "hour": 19, + "minute": 49, + "second": 15, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from [218.19.142.229] (helo=hotmail.com ident=yiuhyotp) by yzordderrex with smtp (Exim 3.35 #1 (Debian)) id 194BE5-0005Zh-00; Sat, 12 Apr 2003 03:58:53 +0100\n", + "expected": { + "from": { + "IpAddr": "218.19.142.229" + }, + "by": { + "Name": "yzordderrex" + }, + "with": "SMTP", + "id": "194BE5-0005Zh-00", + "ident": "yiuhyotp", + "helo": { + "Name": "hotmail.com" + }, + "helo_cmd": "Helo", + "date": { + "year": 2003, + "month": 4, + "day": 12, + "hour": 3, + "minute": 58, + "second": 53, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from mtsbp606.email-info.net (?dXqpg3b0hiH9faI2OxLT94P/YKDD3rQ1?@64.253.199.166) by kde.informatik.uni-kl.de with SMTP; 30 Apr 2003 15:06:29\n", + "expected": { + "from": { + "Name": "mtsbp606.email-info.net" + }, + "by": { + "Name": "kde.informatik.uni-kl.de" + }, + "with": "SMTP", + "ident": "YKDD3rQ1?@64.253.199.166", + "date": { + "year": 2003, + "month": 4, + "day": 30, + "hour": 15, + "minute": 6, + "second": 29, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from TCE-E-7-182-54.bta.net.cn(202.106.182.54) via SMTP by st.tahina.priv.at, id smtpdEDUB8h; Sun Nov 13 14:50:12 2005\n", + "expected": { + "from": { + "Name": "TCE-E-7-182-54.bta.net.cn" + }, + "from_ip": "202.106.182.54", + "by": { + "Name": "st.tahina.priv.at" + }, + "id": "smtpdEDUB8h", + "via": "SMTP", + "date": { + "year": 1914, + "month": 13, + "day": 11, + "hour": 50, + "minute": 12, + "second": 213, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from pl027.nas934.d-osaka.nttpc.ne.jp(61.197.82.27), claiming to be \"foo.woas.net\" via SMTP by st.tahina.priv.at, id smtpd1PBsZT; Sun Nov 13 15:38:52 2005\n", + "expected": { + "from": { + "Name": "pl027.nas934.d-osaka.nttpc.ne.jp" + }, + "from_ip": "61.197.82.27", + "by": { + "Name": "st.tahina.priv.at" + }, + "id": "smtpd1PBsZT", + "via": "SMTP", + "date": { + "year": 1915, + "month": 13, + "day": 11, + "hour": 38, + "minute": 52, + "second": 213, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from itrqtnlnq (lucilleskinner@93.124.107.183 with login) by smtp111.mail.ne1.yahoo.com with SMTP; 17 Jan 2011 08:23:27 -0800 PST\n", + "expected": { + "from": { + "Name": "itrqtnlnq" + }, + "by": { + "Name": "smtp111.mail.ne1.yahoo.com" + }, + "with": "SMTP", + "ident": "lucilleskinner@93.124.107.183", + "date": { + "year": 2011, + "month": 1, + "day": 17, + "hour": 8, + "minute": 23, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from raptor.research.att.com (bala@localhost) by raptor.research.att.com (SGI-8.9.3/8.8.7) with ESMTP id KAA14788 for ; Fri, 7 Mar 2003 10:37:56 -0500 (EST)\n", + "expected": { + "from": { + "Name": "raptor.research.att.com" + }, + "by": { + "Name": "raptor.research.att.com" + }, + "for_": "asrg@example.com", + "with": "ESMTP", + "id": "KAA14788", + "ident": "bala@localhost", + "date": { + "year": 2003, + "month": 3, + "day": 7, + "hour": 10, + "minute": 37, + "second": 56, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from paul (helo=felix) by felix.peema.org with local-esmtp (Exim 4.43) id 1Ccq0j-0002k2-Lk; Fri, 10 Dec 2004 19:01:01 +0000\n", + "expected": { + "from": { + "Name": "paul" + }, + "by": { + "Name": "felix.peema.org" + }, + "with": "ESMTP", + "id": "1Ccq0j-0002k2-Lk", + "helo": { + "Name": "felix" + }, + "helo_cmd": "Helo", + "date": { + "year": 2004, + "month": 12, + "day": 10, + "hour": 19, + "minute": 1, + "second": 1, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from 127.0.0.1 (AVG SMTP 7.0.299 [265.6.8]); Wed, 05 Jan 2005 15:06:48 -0800\n", + "expected": { + "from": { + "IpAddr": "127.0.0.1" + }, + "date": { + "year": 2005, + "month": 1, + "day": 5, + "hour": 15, + "minute": 6, + "second": 48, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from qmail-scanner-general-admin@lists.sourceforge.net by alpha by uid 7791 with qmail-scanner-1.14 (spamassassin: 2.41. Clear:SA:0(-4.1/5.0):. Processed in 0.209512 secs)\n", + "expected": { + "from": { + "Name": "qmail-scanner-general-admin@lists.sourceforge.net" + }, + "by": { + "Name": "uid" + }, + "date": null + } + }, + { + "header": "from DSmith1204@aol.com by imo-m09.mx.aol.com (mail_out_v34.13.) id 7.53.208064a0 (4394); Sat, 11 Jan 2003 23:24:31 -0500 (EST)\n", + "expected": { + "from": { + "Name": "DSmith1204@aol.com" + }, + "by": { + "Name": "imo-m09.mx.aol.com" + }, + "id": "7.53.208064a0", + "date": { + "year": 2003, + "month": 1, + "day": 11, + "hour": 23, + "minute": 24, + "second": 31, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from Unknown/Local ([?.?.?.?]) by mailcity.com; Fri, 17 Jan 2003 15:23:29 -0000\n", + "expected": { + "from": { + "Name": "Unknown" + }, + "by": { + "Name": "mailcity.com" + }, + "date": { + "year": 2003, + "month": 1, + "day": 17, + "hour": 15, + "minute": 23, + "second": 29, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from localhost (mailnull@localhost) by x.org (8.12.6/8.9.3) with SMTP id h2R2iivG093740; Wed, 26 Mar 2003 20:44:44 -0600 \n", + "expected": { + "from": { + "Name": "localhost" + }, + "by": { + "Name": "x.org" + }, + "with": "SMTP", + "id": "h2R2iivG093740", + "ident": "mailnull@localhost", + "date": { + "year": 2003, + "month": 3, + "day": 26, + "hour": 20, + "minute": 44, + "second": 44, + "tz_before_gmt": true, + "tz_hour": 6, + "tz_minute": 0 + } + } + }, + { + "header": "from localhost (localhost [127.0.0.1]) (uid 500) by mail with local; Tue, 07 Jan 2003 11:40:47 -0600\n", + "expected": { + "from": { + "Name": "localhost" + }, + "from_ip": "127.0.0.1", + "by": { + "Name": "mail" + }, + "with": "Local", + "date": { + "year": 2003, + "month": 1, + "day": 7, + "hour": 11, + "minute": 40, + "second": 47, + "tz_before_gmt": true, + "tz_hour": 6, + "tz_minute": 0 + } + } + }, + { + "header": "from olgisoft.com (127.0.0.1) by 127.0.0.1 (EzMTS MTSSmtp 1.55d5) ; Thu, 20 Mar 03 10:06:43 +0100 for \n", + "expected": { + "from": { + "Name": "olgisoft.com" + }, + "from_ip": "127.0.0.1", + "by": { + "IpAddr": "127.0.0.1" + }, + "for_": "asrg@ietf.org", + "date": { + "year": 1903, + "month": 3, + "day": 20, + "hour": 10, + "minute": 6, + "second": 43, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from casper.ghostscript.com (raph@casper [127.0.0.1]) h148aux8016336verify=FAIL); Tue, 4 Feb 2003 00:36:56 -0800\n", + "expected": { + "from": { + "Name": "casper.ghostscript.com" + }, + "from_ip": "127.0.0.1", + "ident": "raph@casper", + "date": { + "year": 2003, + "month": 2, + "day": 4, + "hour": 0, + "minute": 36, + "second": 56, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 + } + } + }, + { + "header": "from (AUTH: e40a9cea) by vqx.net with esmtp (courier-0.40) for ; Mon, 03 Mar 2003 14:49:28 +0000\n", + "expected": { + "by": { + "Name": "vqx.net" + }, + "for_": "asrg@ietf.org", + "with": "ESMTP", + "date": { + "year": 2003, + "month": 3, + "day": 3, + "hour": 14, + "minute": 49, + "second": 28, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from localhost (localhost [[UNIX: localhost]]) by home.barryodonovan.com (8.12.11/8.12.11/Submit) id iBADHRP6011034; Fri, 10 Dec 2004 13:17:27 GMT\n", + "expected": { + "from": { + "Name": "localhost" + }, + "by": { + "Name": "home.barryodonovan.com" + }, + "id": "iBADHRP6011034", + "date": { + "year": 2004, + "month": 12, + "day": 10, + "hour": 13, + "minute": 17, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from dc-mail-3102.iad3.amazon.com by mail-store-2001.amazon.com with ESMTP (peer crosscheck: dc-mail-3102.iad3.amazon.com)\n", + "expected": { + "from": { + "Name": "dc-mail-3102.iad3.amazon.com" + }, + "by": { + "Name": "mail-store-2001.amazon.com" + }, + "with": "ESMTP", + "date": null + } + }, + { + "header": "from GWGC6-MTA by gc6.jefferson.co.us with Novell_GroupWise; Tue, 30 Nov 2004 10:09:15 -0700\n", + "expected": { + "from": { + "Name": "GWGC6-MTA" + }, + "by": { + "Name": "gc6.jefferson.co.us" + }, + "date": { + "year": 2004, + "month": 11, + "day": 30, + "hour": 10, + "minute": 9, + "second": 15, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from no.name.available by [165.224.43.143] via smtpd (for [165.224.216.89]) with ESMTP; Fri, 28 Jan 2005 13:06:39 -0500\n", + "expected": { + "from": { + "Name": "no.name.available" + }, + "by": { + "IpAddr": "165.224.43.143" + }, + "with": "ESMTP", + "via": "smtpd", + "date": { + "year": 2005, + "month": 1, + "day": 28, + "hour": 13, + "minute": 6, + "second": 39, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from no.name.available by [165.224.216.88] via smtpd (for lists.sourceforge.net [66.35.250.206]) with ESMTP; Fri, 28 Jan 2005 15:42:30 -0500\n", + "expected": { + "from": { + "Name": "no.name.available" + }, + "by": { + "IpAddr": "165.224.216.88" + }, + "with": "ESMTP", + "via": "smtpd", + "date": { + "year": 2005, + "month": 1, + "day": 28, + "hour": 15, + "minute": 42, + "second": 30, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from 156.56.111.196 by blazing.arsecandle.org (envelope-from , uid 502) with qmail-scanner-1.24 (clamdscan: 0.80/594. f-prot: 4.4.2/3.14.11. Clear:RC:0(156.56.111.196):. Processed in 0.288806 secs); 06 Feb 2005 21:11:38 -0000\n", + "expected": { + "from": { + "IpAddr": "156.56.111.196" + }, + "by": { + "Name": "blazing.arsecandle.org" + }, + "date": { + "year": 2005, + "month": 2, + "day": 6, + "hour": 21, + "minute": 11, + "second": 38, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from mmail by argon.connect.org.uk with local (connectmail/exim) id 18tOsg-0008FX-00; Thu, 13 Mar 2003 09:20:06 +0000\n", + "expected": { + "from": { + "Name": "mmail" + }, + "by": { + "Name": "argon.connect.org.uk" + }, + "with": "Local", + "id": "18tOsg-0008FX-00", + "date": { + "year": 2003, + "month": 3, + "day": 13, + "hour": 9, + "minute": 20, + "second": 6, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from testintranator.net.vm ([unix socket])_ by testintranator.net.vm (Cyrus v2.3.14) with LMTPA;_ Tue, 21 Jul 2009 14:34:14 +0200\n", + "expected": { + "from": { + "Name": "testintranator.net.vm" + }, + "by": { + "Name": "testintranator.net.vm" + }, + "with": "LMTPA", + "date": { + "year": 2009, + "month": 7, + "day": 21, + "hour": 14, + "minute": 34, + "second": 14, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from CATHY.IJS.SI by CATHY.IJS.SI (PMDF V4.3-10 #8779) id <01KTSSR50NSW001MXN@CATHY.IJS.SI>; Fri, 21 Mar 2003 20:50:56 +0100\n", + "expected": { + "from": { + "Name": "CATHY.IJS.SI" + }, + "by": { + "Name": "CATHY.IJS.SI" + }, + "id": "01KTSSR50NSW001MXN@CATHY.IJS.SI", + "date": { + "year": 2003, + "month": 3, + "day": 21, + "hour": 20, + "minute": 50, + "second": 56, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from MATT_LINUX by hippo.star.co.uk via smtpd (for mail.webnote.net [193.120.211.219]) with SMTP; 3 Jul 2002 15:43:50 UT\n", + "expected": { + "from": { + "Name": "MATT_LINUX" + }, + "by": { + "Name": "hippo.star.co.uk" + }, + "with": "SMTP", + "via": "smtpd", + "date": { + "year": 2002, + "month": 7, + "day": 3, + "hour": 15, + "minute": 43, + "second": 50, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from cp-its-ieg01.mail.saic.com by cpmx.mail.saic.com for me@jmason.org; Tue, 23 Jul 2002 14:09:10 -0700\n", + "expected": { + "from": { + "Name": "cp-its-ieg01.mail.saic.com" + }, + "by": { + "Name": "cpmx.mail.saic.com" + }, + "for_": "me@jmason.org", + "date": { + "year": 2002, + "month": 7, + "day": 23, + "hour": 14, + "minute": 9, + "second": 10, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from senmail2.senate.gov with LMTP by senmail2 (3.0.2/sieved-3-0-build-942) for ; Fri, 30 Jun 2006 10:58:41 -0400\n", + "expected": { + "from": { + "Name": "senmail2.senate.gov" + }, + "by": { + "Name": "senmail2" + }, + "for_": "example@vandinter.org", + "with": "LMTP", + "date": { + "year": 2006, + "month": 6, + "day": 30, + "hour": 10, + "minute": 58, + "second": 41, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from zimbramail.artsit.org.uk (unverified) by MAILSWEEP.birminghamartsit.org.uk (Clearswift SMTPRS 5.1.7) with ESMTP id for ; Tue, 30 May 2006 15:56:15 +0100\n", + "expected": { + "from": { + "Name": "zimbramail.artsit.org.uk" + }, + "by": { + "Name": "MAILSWEEP.birminghamartsit.org.uk" + }, + "for_": "discuss@lists.surbl.org", + "with": "ESMTP", + "id": "T78926b35f2c0a80003da8@MAILSWEEP.birminghamartsit.org.uk", + "date": { + "year": 2006, + "month": 5, + "day": 30, + "hour": 15, + "minute": 56, + "second": 15, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "from MjA3NDc4Mg (unknown) by ismtpd0001p1lon1.sendgrid.net (SG) with HTTP id aqHKNX2kSp-HiqspAa-uvw for ; Thu, 02 Apr 2020 07:53:55.516 +0000 (UTC)\n", + "expected": { + "from": { + "Name": "MjA3NDc4Mg" + }, + "by": { + "Name": "ismtpd0001p1lon1.sendgrid.net" + }, + "for_": "email@e.example.com", + "with": "HTTP", + "id": "aqHKNX2kSp-HiqspAa-uvw", + "date": { + "year": 2020, + "month": 4, + "day": 2, + "hour": 7, + "minute": 53, + "second": 0, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from localhost (example.com [local]) by example.com (OpenSMTPD) with ESMTPA id 5db34e0d for ; Tue, 7 Apr 2020 01:38:29 -0600 (MDT)\n", + "expected": { + "from": { + "Name": "localhost" + }, + "from_iprev": "example.com", + "by": { + "Name": "example.com" + }, + "for_": "email@example.com", + "with": "ESMTPA", + "id": "5db34e0d", + "date": { + "year": 2020, + "month": 4, + "day": 7, + "hour": 1, + "minute": 38, + "second": 29, + "tz_before_gmt": true, + "tz_hour": 6, + "tz_minute": 0 + } + } + }, + { + "header": "from DL1GSPMX02 (dl1gspmx02.gamestop.com) by email.ebgames.com (LSMTP for Windows NT v1.1b) with SMTP id <21.000575A0@email.ebgames.com>; Tue, 12 Sep 2006 21:06:43 -0500\n", + "expected": { + "from": { + "Name": "DL1GSPMX02" + }, + "from_iprev": "dl1gspmx02.gamestop.com", + "by": { + "Name": "email.ebgames.com" + }, + "with": "SMTP", + "id": "21.000575A0@email.ebgames.com", + "date": { + "year": 2006, + "month": 9, + "day": 12, + "hour": 21, + "minute": 6, + "second": 43, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from ([127.0.0.1]) with MailEnable ESMTP; Wed, 10 Jul 2019 10:29:59 +0300\n", + "expected": { + "from_ip": "127.0.0.1", + "with": "ESMTP", + "date": { + "year": 2019, + "month": 7, + "day": 10, + "hour": 10, + "minute": 29, + "second": 59, + "tz_before_gmt": false, + "tz_hour": 3, + "tz_minute": 0 + } + } + }, + { + "header": "from facebook.com (RrlQsUbrndsQ6/zbJaSzSPcmy3GwqE5h6IukkE5GGBIJgonAFnoQE3L+9tv2TU3e 2401:db00:1110:50e8:face:0000:002f:0000) by facebook.com with Thrift id 423753524b5011e9a83e248a0796a3b2-169bd530; Wed, 20 Mar 2019 13:39:29 -0700\n", + "expected": { + "from": { + "Name": "facebook.com" + }, + "from_ip": "2401:db00:1110:50e8:face:0:2f:0", + "by": { + "Name": "facebook.com" + }, + "id": "423753524b5011e9a83e248a0796a3b2-169bd530", + "date": { + "year": 2019, + "month": 3, + "day": 20, + "hour": 13, + "minute": 39, + "second": 29, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from 384836569573 named unknown by gmailapi.google.com with HTTPREST; Wed, 6 Mar 2019 03:39:24 -0500\n", + "expected": { + "from": { + "Name": "384836569573" + }, + "by": { + "Name": "gmailapi.google.com" + }, + "with": "HTTP", + "date": { + "year": 2019, + "month": 3, + "day": 6, + "hour": 3, + "minute": 39, + "second": 24, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "from mail.payex.com id ; Wed, 05 Sep 2018 01:14:43 +0200\n", + "expected": { + "from": { + "Name": "mail.payex.com" + }, + "id": "B5b8f11e30004", + "date": { + "year": 2018, + "month": 9, + "day": 5, + "hour": 1, + "minute": 14, + "second": 43, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "from [<4124973-137966-3089@be2.maropost.com>] ([<4124973-137966-3089@be2.maropost.com>] helo=maropost.com) by 643852-mailer2 (envelope-from 4124973-137966-3089@be2.maropost.com) Jetsend MTA 0.0.1 with ESMTP; Fri Sep 14 14:36:56 EDT 2018\n", + "expected": { + "by": { + "Name": "643852-mailer2" + }, + "with": "ESMTP", + "ident": "4124973-137966-3089@be2.maropost.com", + "helo": { + "Name": "maropost.com" + }, + "helo_cmd": "Helo", + "date": { + "year": 1914, + "month": 14, + "day": 9, + "hour": 36, + "minute": 56, + "second": 226, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from maroon.pobox.com (localhost [127.0.0.1]) by maroon.pobox.com (Postfix) with ESMTP id EA14340A31F; Wed, 15 Jun 2011 10:42:35 -0400 (EDT)\n", + "expected": { + "from": { + "Name": "maroon.pobox.com" + }, + "from_ip": "127.0.0.1", + "by": { + "Name": "maroon.pobox.com" + }, + "with": "ESMTP", + "id": "EA14340A31F", + "date": { + "year": 2011, + "month": 6, + "day": 15, + "hour": 10, + "minute": 42, + "second": 35, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from mail-qw0-f46.google.com (mail-qw0-f46.google.com [209.85.216.46]) by maroon.pobox.com (Postfix) with ESMTPS id 70BCC40A1DB for
; Wed, 15 Jun 2011 10:42:13 -0400 (EDT)\n", + "expected": { + "from": { + "Name": "mail-qw0-f46.google.com" + }, + "from_ip": "209.85.216.46", + "from_iprev": "mail-qw0-f46.google.com", + "by": { + "Name": "maroon.pobox.com" + }, + "with": "ESMTPS", + "id": "70BCC40A1DB", + "date": { + "year": 2011, + "month": 6, + "day": 15, + "hour": 10, + "minute": 42, + "second": 13, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "from [10.231.252.223] (79.sub-174-252-72.myvzw.com [174.252.72.79]) by mx.google.com with ESMTPS id m16sm345129qck.28.2011.06.15.07.42.02 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 15 Jun 2011 07:42:08 -0700 (PDT)\n", + "expected": { + "from": { + "IpAddr": "10.231.252.223" + }, + "from_ip": "174.252.72.79", + "from_iprev": "79.sub-174-252-72.myvzw.com", + "by": { + "Name": "mx.google.com" + }, + "with": "ESMTPS", + "tls_version": "TLSv1_0", + "id": "m16sm345129qck.28.2011.06.15.07.42.02", + "date": { + "year": 2011, + "month": 6, + "day": 15, + "hour": 7, + "minute": 42, + "second": 8, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 + } + } + }, + { + "header": "from mail-eopbgr60122.outbound.protection.outlook.com (HELO EUR04-DB3-obe.outb) server-7.tower-with AES256-GCM-SHA384 encrypted SMTP; 13 Sep 2018 14:47:44 -0000\n", + "expected": { + "from": { + "Name": "mail-eopbgr60122.outbound.protection.outlook.com" + }, + "tls_cipher": "AES256-GCM-SHA384", + "helo": { + "Name": "EUR04-DB3-obe.outb" + }, + "helo_cmd": "Helo", + "date": { + "year": 2018, + "month": 9, + "day": 13, + "hour": 14, + "minute": 47, + "second": 44, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from DB6PR07MB3286.eurprd07.prod.outlook.com (10.175.233.33) by DB6PR07MB3384.eurprd07.prod.outlook.com (10.175.234.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.11; Thu, 13 Sep 2018 14:47:44 +0000\n", + "expected": { + "from": { + "Name": "DB6PR07MB3286.eurprd07.prod.outlook.com" + }, + "from_ip": "10.175.233.33", + "by": { + "Name": "DB6PR07MB3384.eurprd07.prod.outlook.com" + }, + "with": "SMTP", + "tls_version": "TLSv1_2", + "tls_cipher": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "id": "15.20.1143.11", + "date": { + "year": 2018, + "month": 9, + "day": 13, + "hour": 14, + "minute": 47, + "second": 44, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "from DB6PR07MB3286.eurprd07.prod.outlook.com ([fe80::ccea:aa3a:fbcf:883f]) by DB6PR07MB3286.eurprd07.prod.outlook.com ([fe80::ccea:aa3a:fbcf:883f%6]) with mapi id 15.20.1164.0; 14:47:44 +0000\n", + "expected": { + "from": { + "Name": "DB6PR07MB3286.eurprd07.prod.outlook.com" + }, + "from_ip": "fe80::ccea:aa3a:fbcf:883f", + "by": { + "Name": "DB6PR07MB3286.eurprd07.prod.outlook.com" + }, + "id": "15.20.1164.0", + "date": null + } + }, + { + "header": "FROM hackers.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.14.81]) BY madman.mr.itd.umich.edu ID 434B508E.174A6.13932 ; 11 Oct 2005 01:41:34 -0400\n", + "expected": { + "from": { + "Name": "hackers.mr.itd.umich.edu" + }, + "from_ip": "141.211.14.81", + "from_iprev": "smtp.mail.umich.edu", + "by": { + "Name": "madman.mr.itd.umich.edu" + }, + "id": "434B508E.174A6.13932", + "date": { + "year": 2005, + "month": 10, + "day": 11, + "hour": 1, + "minute": 41, + "second": 34, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "FROM [192.168.1.24] (s233-64-90-216.try.wideopenwest.com [64.233.216.90]) BY hackers.mr.itd.umich.edu ID 434B5051.8CDE5.15436 ; 11 Oct 2005 01:40:33 -0400\n", + "expected": { + "from": { + "IpAddr": "192.168.1.24" + }, + "from_ip": "64.233.216.90", + "from_iprev": "s233-64-90-216.try.wideopenwest.com", + "by": { + "Name": "hackers.mr.itd.umich.edu" + }, + "id": "434B5051.8CDE5.15436", + "date": { + "year": 2005, + "month": 10, + "day": 11, + "hour": 1, + "minute": 40, + "second": 33, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + }, + { + "header": "FROM helo (1.2.3.4 [1.2.3.4]) BY xxx.com (Rockliffe SMTPRA 10.3.0) WITH SMTP ID FOR ; Tue, 6 Nov 2018 07:41:26 +0200\n", + "expected": { + "from": { + "Name": "helo" + }, + "from_ip": "1.2.3.4", + "by": { + "Name": "xxx.com" + }, + "for_": "foo@bar.net", + "with": "SMTP", + "id": "B0065361981@xxx.com", + "date": { + "year": 2018, + "month": 11, + "day": 6, + "hour": 7, + "minute": 41, + "second": 26, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + } + }, + { + "header": "(from localhost [24.180.47.240]) by host.name (NAVGW 2.5.2.12) with SMTP id M2006060503484615455 for ; Mon, 05 Jun 2006 03:48:47 +0100\n", + "expected": { + "from": { + "Name": "localhost" + }, + "from_ip": "24.180.47.240", + "by": { + "Name": "host.name" + }, + "for_": "user@domain.co.uk", + "with": "SMTP", + "id": "M2006060503484615455", + "date": { + "year": 2006, + "month": 6, + "day": 5, + "hour": 3, + "minute": 48, + "second": 47, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "(from username@localhost) by home.example.com (8.12.11/8.12.11/Submit) id iBADHRP6011034; Fri, 10 Dec 2004 13:17:27 GMT\n", + "expected": { + "from": { + "Name": "username@localhost" + }, + "by": { + "Name": "home.example.com" + }, + "id": "iBADHRP6011034", + "date": { + "year": 2004, + "month": 12, + "day": 10, + "hour": 13, + "minute": 17, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "(from vashugins@juno.com) by m06.lax.untd.com (jqueuemail) id LRVB3JAJ; Fri, 02 Jun 2006 08:15:21 PDT\n", + "expected": { + "from": { + "Name": "vashugins@juno.com" + }, + "by": { + "Name": "m06.lax.untd.com" + }, + "id": "LRVB3JAJ", + "date": { + "year": 2006, + "month": 6, + "day": 2, + "hour": 8, + "minute": 15, + "second": 21, + "tz_before_gmt": true, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "(qmail 27981 invoked by uid 225); 14 Mar 2003 07:24:34 -0000\n", + "expected": { + "date": { + "year": 2003, + "month": 3, + "day": 14, + "hour": 7, + "minute": 24, + "second": 34, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "(qmail 84907 invoked from network); 13 Feb 2003 20:59:28 -0000\n", + "expected": { + "from": { + "Name": "network" + }, + "date": { + "year": 2003, + "month": 2, + "day": 13, + "hour": 20, + "minute": 59, + "second": 28, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "(ofmipd 208.31.42.38); 17 Mar 2003 04:09:01 -0000\n", + "expected": { + "date": { + "year": 2003, + "month": 3, + "day": 17, + "hour": 4, + "minute": 9, + "second": 1, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "with ECARTIS (v1.0.0; list bind-announce); Fri, 18 Aug 2006 07:19:58 +0000 (UTC)\n", + "expected": { + "date": { + "year": 2006, + "month": 8, + "day": 18, + "hour": 7, + "minute": 19, + "second": 58, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "by faerber.muc.de (OpenXP/32 v3.9.4 (Win32) alpha @ 2003-03-07-1751d); 07 Mar 2003 22:10:29 +0000\n", + "expected": { + "by": { + "Name": "faerber.muc.de" + }, + "date": { + "year": 2003, + "month": 3, + "day": 7, + "hour": 22, + "minute": 10, + "second": 29, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + } + }, + { + "header": "by x.x.org (bulk_mailer v1.13); Wed, 26 Mar 2003 20:44:41 -0600\n", + "expected": { + "by": { + "Name": "x.x.org" + }, + "date": { + "year": 2003, + "month": 3, + "day": 26, + "hour": 20, + "minute": 44, + "second": 41, + "tz_before_gmt": true, + "tz_hour": 6, + "tz_minute": 0 + } + } + }, + { + "header": "by SPIDERMAN with Internet Mail Service (5.5.2653.19) id <19AF8VY2>; Tue, 25 Mar 2003 11:58:27 -0500\n", + "expected": { + "by": { + "Name": "SPIDERMAN" + }, + "id": "19AF8VY2", + "date": { + "year": 2003, + "month": 3, + "day": 25, + "hour": 11, + "minute": 58, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + } + }, + { + "header": "by oak.ein.cz (Postfix, from userid 1002) id DABBD1BED3; Thu, 13 Feb 2003 14:02:21 +0100 (CET)\n", + "expected": { + "from": { + "Name": "userid" + }, + "by": { + "Name": "oak.ein.cz" + }, + "id": "DABBD1BED3", + "date": { + "year": 2003, + "month": 2, + "day": 13, + "hour": 14, + "minute": 2, + "second": 21, + "tz_before_gmt": false, + "tz_hour": 1, + "tz_minute": 0 + } + } + }, + { + "header": "by OTM-MIX(otm-mix00) id k5N1aDtp040896; Fri, 23 Jun 2006 10:36:14 +0900 (JST)\n", + "expected": { + "by": { + "Name": "OTM-MIX" + }, + "id": "k5N1aDtp040896", + "date": { + "year": 2006, + "month": 6, + "day": 23, + "hour": 10, + "minute": 36, + "second": 14, + "tz_before_gmt": false, + "tz_hour": 9, + "tz_minute": 0 + } + } + }, + { + "header": "; Tue, 23 May 2006 13:06:35 -0400\n", + "expected": { + "date": { + "year": 2006, + "month": 5, + "day": 23, + "hour": 13, + "minute": 6, + "second": 35, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + } + } +] \ No newline at end of file diff --git a/src/core/address.rs b/src/core/address.rs new file mode 100644 index 0000000..6d12b73 --- /dev/null +++ b/src/core/address.rs @@ -0,0 +1,44 @@ +/* + * Copyright Stalwart Labs Ltd. See the COPYING + * file at the top-level directory of this distribution. + * + * Licensed under the Apache License, Version 2.0 or the MIT license + * , at your + * option. This file may not be copied, modified, or distributed + * except according to those terms. + */ + +use crate::{Addr, Group}; + +impl<'x> Group<'x> { + pub fn new(name: &'x str, addresses: Vec>) -> Self { + Self { + name: Some(name.into()), + addresses, + } + } + + pub fn into_owned(self) -> Group<'static> { + Group { + name: self.name.map(|s| s.into_owned().into()), + addresses: self.addresses.into_iter().map(|a| a.into_owned()).collect(), + } + } +} + +impl<'x> Addr<'x> { + pub fn new(name: Option<&'x str>, address: &'x str) -> Self { + Self { + name: name.map(|name| name.into()), + address: Some(address.into()), + } + } + + pub fn into_owned(self) -> Addr<'static> { + Addr { + name: self.name.map(|s| s.into_owned().into()), + address: self.address.map(|s| s.into_owned().into()), + } + } +} diff --git a/src/core/body.rs b/src/core/body.rs new file mode 100644 index 0000000..cfa52bb --- /dev/null +++ b/src/core/body.rs @@ -0,0 +1,58 @@ +/* + * Copyright Stalwart Labs Ltd. See the COPYING + * file at the top-level directory of this distribution. + * + * Licensed under the Apache License, Version 2.0 or the MIT license + * , at your + * option. This file may not be copied, modified, or distributed + * except according to those terms. + */ + +use crate::{AttachmentIterator, BodyPartIterator, Message, MessagePart, MessagePartId, PartType}; + +impl<'x> PartType<'x> { + #[allow(clippy::len_without_is_empty)] + pub fn len(&self) -> usize { + match self { + PartType::Text(v) | PartType::Html(v) => v.len(), + PartType::Binary(v) | PartType::InlineBinary(v) => v.len(), + PartType::Message(v) => v.raw_message.len(), + PartType::Multipart(_) => 0, + } + } +} + +impl<'x> BodyPartIterator<'x> { + pub(crate) fn new(message: &'x Message<'x>, list: &'x [MessagePartId]) -> BodyPartIterator<'x> { + BodyPartIterator { + message, + list, + pos: -1, + } + } +} + +impl<'x> Iterator for BodyPartIterator<'x> { + type Item = &'x MessagePart<'x>; + + fn next(&mut self) -> Option { + self.pos += 1; + self.message.parts.get(*self.list.get(self.pos as usize)?) + } +} + +impl<'x> AttachmentIterator<'x> { + pub(crate) fn new(message: &'x Message<'x>) -> AttachmentIterator<'x> { + AttachmentIterator { message, pos: -1 } + } +} + +impl<'x> Iterator for AttachmentIterator<'x> { + type Item = &'x MessagePart<'x>; + + fn next(&mut self) -> Option { + self.pos += 1; + self.message.attachment(self.pos as usize) + } +} diff --git a/src/core/header.rs b/src/core/header.rs new file mode 100644 index 0000000..34155ee --- /dev/null +++ b/src/core/header.rs @@ -0,0 +1,747 @@ +/* + * Copyright Stalwart Labs Ltd. See the COPYING + * file at the top-level directory of this distribution. + * + * Licensed under the Apache License, Version 2.0 or the MIT license + * , at your + * option. This file may not be copied, modified, or distributed + * except according to those terms. + */ + +use core::fmt; +use std::hash::Hash; +use std::{borrow::Cow, fmt::Display}; + +use crate::{ + ContentType, DateTime, GetHeader, Header, HeaderName, HeaderValue, Host, Message, MessagePart, + MessagePartId, MimeHeaders, PartType, Received, RfcHeader, +}; + +impl<'x> Header<'x> { + /// Returns the header name + pub fn name(&self) -> &str { + self.name.as_str() + } + + /// Returns the parsed header value + pub fn value(&self) -> &HeaderValue { + &self.value + } + + /// Returns the raw offset start + pub fn offset_start(&self) -> usize { + self.offset_start + } + + /// Returns the raw offset end + pub fn offset_end(&self) -> usize { + self.offset_end + } + + /// Returns the raw offset of the header name + pub fn offset_field(&self) -> usize { + self.offset_field + } + + /// Returns an owned version of the header + pub fn into_owned(self) -> Header<'static> { + Header { + name: self.name.into_owned(), + value: self.value.into_owned(), + offset_field: self.offset_field, + offset_start: self.offset_start, + offset_end: self.offset_end, + } + } +} + +impl<'x> HeaderValue<'x> { + pub fn is_empty(&self) -> bool { + *self == HeaderValue::Empty + } + + pub fn unwrap_text(self) -> Cow<'x, str> { + match self { + HeaderValue::Text(s) => s, + _ => panic!("HeaderValue::unwrap_text called on non-Text value"), + } + } + + pub fn unwrap_datetime(self) -> DateTime { + match self { + HeaderValue::DateTime(d) => d, + _ => panic!("HeaderValue::unwrap_datetime called on non-DateTime value"), + } + } + + pub fn unwrap_content_type(self) -> ContentType<'x> { + match self { + HeaderValue::ContentType(c) => c, + _ => panic!("HeaderValue::unwrap_content_type called on non-ContentType value"), + } + } + + pub fn unwrap_received(self) -> Received<'x> { + match self { + HeaderValue::Received(r) => *r, + _ => panic!("HeaderValue::unwrap_received called on non-Received value"), + } + } + + pub fn as_text(&self) -> Option<&str> { + match *self { + HeaderValue::Text(ref s) => Some(s), + HeaderValue::TextList(ref l) => l.last()?.as_ref().into(), + _ => None, + } + } + + pub fn as_text_list(&self) -> Option> { + match *self { + HeaderValue::Text(ref s) => Some(vec![s.as_ref()]), + HeaderValue::TextList(ref l) => Some(l.iter().map(|l| l.as_ref()).collect()), + _ => None, + } + } + + pub fn as_received(&self) -> Option<&Received> { + match *self { + HeaderValue::Received(ref r) => Some(r), + _ => None, + } + } + + pub fn content_type(&self) -> &ContentType<'x> { + match *self { + HeaderValue::ContentType(ref ct) => ct, + _ => panic!( + "HeaderValue::content_type called on non-ContentType: {:?}", + self + ), + } + } + + pub fn as_content_type_ref(&self) -> Option<&ContentType> { + match *self { + HeaderValue::ContentType(ref c) => Some(c), + _ => None, + } + } + + pub fn as_datetime_ref(&self) -> Option<&DateTime> { + match *self { + HeaderValue::DateTime(ref d) => Some(d), + _ => None, + } + } + + pub fn into_owned(self) -> HeaderValue<'static> { + match self { + HeaderValue::Address(addr) => HeaderValue::Address(addr.into_owned()), + HeaderValue::AddressList(list) => { + HeaderValue::AddressList(list.into_iter().map(|addr| addr.into_owned()).collect()) + } + HeaderValue::Group(group) => HeaderValue::Group(group.into_owned()), + HeaderValue::GroupList(list) => { + HeaderValue::GroupList(list.into_iter().map(|group| group.into_owned()).collect()) + } + HeaderValue::Text(text) => HeaderValue::Text(text.into_owned().into()), + HeaderValue::TextList(list) => HeaderValue::TextList( + list.into_iter() + .map(|text| text.into_owned().into()) + .collect(), + ), + HeaderValue::DateTime(datetime) => HeaderValue::DateTime(datetime), + HeaderValue::ContentType(ct) => HeaderValue::ContentType(ContentType { + c_type: ct.c_type.into_owned().into(), + c_subtype: ct.c_subtype.map(|s| s.into_owned().into()), + attributes: ct.attributes.map(|attributes| { + attributes + .into_iter() + .map(|(k, v)| (k.into_owned().into(), v.into_owned().into())) + .collect() + }), + }), + HeaderValue::Received(rcvd) => HeaderValue::Received(Box::new(rcvd.into_owned())), + HeaderValue::Empty => HeaderValue::Empty, + } + } + + pub fn len(&self) -> usize { + match self { + HeaderValue::Text(text) => text.len(), + HeaderValue::TextList(list) => list.iter().map(|t| t.len()).sum(), + HeaderValue::Address(a) => { + a.name.as_ref().map_or(0, |a| a.len()) + a.address.as_ref().map_or(0, |a| a.len()) + } + HeaderValue::AddressList(list) => list + .iter() + .map(|a| { + a.name.as_ref().map_or(0, |a| a.len()) + + a.address.as_ref().map_or(0, |a| a.len()) + }) + .sum(), + HeaderValue::Group(group) => group + .addresses + .iter() + .map(|a| { + a.name.as_ref().map_or(0, |a| a.len()) + + a.address.as_ref().map_or(0, |a| a.len()) + }) + .sum(), + HeaderValue::GroupList(grouplist) => grouplist + .iter() + .flat_map(|g| g.addresses.iter()) + .map(|a| { + a.name.as_ref().map_or(0, |a| a.len()) + + a.address.as_ref().map_or(0, |a| a.len()) + }) + .sum(), + HeaderValue::DateTime(_) => 24, + HeaderValue::ContentType(ct) => { + ct.c_type.len() + + ct.c_subtype.as_ref().map_or(0, |s| s.len()) + + ct.attributes + .as_ref() + .map_or(0, |at| at.iter().map(|(a, b)| a.len() + b.len()).sum()) + } + HeaderValue::Received(_) => 1, + HeaderValue::Empty => 0, + } + } +} + +impl PartialEq for HeaderName<'_> { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Rfc(a), Self::Rfc(b)) => a == b, + (Self::Other(a), Self::Other(b)) => a.eq_ignore_ascii_case(b), + _ => false, + } + } +} + +impl<'x> Hash for HeaderName<'x> { + fn hash(&self, state: &mut H) { + match self { + HeaderName::Rfc(rfc) => rfc.hash(state), + HeaderName::Other(value) => { + for ch in value.as_bytes() { + ch.to_ascii_lowercase().hash(state) + } + } + } + } +} + +impl Eq for HeaderName<'_> {} + +impl<'x> HeaderName<'x> { + pub fn as_str(&self) -> &str { + match self { + HeaderName::Rfc(header) => header.as_str(), + HeaderName::Other(name) => name.as_ref(), + } + } + + pub fn to_owned(&self) -> HeaderName<'static> { + match self { + HeaderName::Rfc(header) => HeaderName::Rfc(*header), + HeaderName::Other(name) => HeaderName::Other(name.clone().into_owned().into()), + } + } + + pub fn into_owned(self) -> HeaderName<'static> { + match self { + HeaderName::Rfc(header) => HeaderName::Rfc(header), + HeaderName::Other(name) => HeaderName::Other(name.into_owned().into()), + } + } + + pub fn unwrap(self) -> String { + match self { + HeaderName::Rfc(header) => header.as_str().to_owned(), + HeaderName::Other(name) => name.into_owned(), + } + } + + /// Returns true if it is a MIME header. + pub fn is_mime_header(&self) -> bool { + match self { + HeaderName::Rfc(header) => header.is_mime_header(), + HeaderName::Other(_) => false, + } + } + + /// Returns the lenght of the header + pub fn len(&self) -> usize { + match self { + HeaderName::Rfc(name) => name.len(), + HeaderName::Other(name) => name.len(), + } + } + + pub fn is_empty(&self) -> bool { + false + } +} + +impl RfcHeader { + pub fn as_str(&self) -> &'static str { + match self { + RfcHeader::Subject => "Subject", + RfcHeader::From => "From", + RfcHeader::To => "To", + RfcHeader::Cc => "Cc", + RfcHeader::Date => "Date", + RfcHeader::Bcc => "Bcc", + RfcHeader::ReplyTo => "Reply-To", + RfcHeader::Sender => "Sender", + RfcHeader::Comments => "Comments", + RfcHeader::InReplyTo => "In-Reply-To", + RfcHeader::Keywords => "Keywords", + RfcHeader::Received => "Received", + RfcHeader::MessageId => "Message-ID", + RfcHeader::References => "References", + RfcHeader::ReturnPath => "Return-Path", + RfcHeader::MimeVersion => "MIME-Version", + RfcHeader::ContentDescription => "Content-Description", + RfcHeader::ContentId => "Content-ID", + RfcHeader::ContentLanguage => "Content-Language", + RfcHeader::ContentLocation => "Content-Location", + RfcHeader::ContentTransferEncoding => "Content-Transfer-Encoding", + RfcHeader::ContentType => "Content-Type", + RfcHeader::ContentDisposition => "Content-Disposition", + RfcHeader::ResentTo => "Resent-To", + RfcHeader::ResentFrom => "Resent-From", + RfcHeader::ResentBcc => "Resent-Bcc", + RfcHeader::ResentCc => "Resent-Cc", + RfcHeader::ResentSender => "Resent-Sender", + RfcHeader::ResentDate => "Resent-Date", + RfcHeader::ResentMessageId => "Resent-Message-ID", + RfcHeader::ListArchive => "List-Archive", + RfcHeader::ListHelp => "List-Help", + RfcHeader::ListId => "List-ID", + RfcHeader::ListOwner => "List-Owner", + RfcHeader::ListPost => "List-Post", + RfcHeader::ListSubscribe => "List-Subscribe", + RfcHeader::ListUnsubscribe => "List-Unsubscribe", + } + } + + pub fn len(&self) -> usize { + match self { + RfcHeader::Subject => "Subject".len(), + RfcHeader::From => "From".len(), + RfcHeader::To => "To".len(), + RfcHeader::Cc => "Cc".len(), + RfcHeader::Date => "Date".len(), + RfcHeader::Bcc => "Bcc".len(), + RfcHeader::ReplyTo => "Reply-To".len(), + RfcHeader::Sender => "Sender".len(), + RfcHeader::Comments => "Comments".len(), + RfcHeader::InReplyTo => "In-Reply-To".len(), + RfcHeader::Keywords => "Keywords".len(), + RfcHeader::Received => "Received".len(), + RfcHeader::MessageId => "Message-ID".len(), + RfcHeader::References => "References".len(), + RfcHeader::ReturnPath => "Return-Path".len(), + RfcHeader::MimeVersion => "MIME-Version".len(), + RfcHeader::ContentDescription => "Content-Description".len(), + RfcHeader::ContentId => "Content-ID".len(), + RfcHeader::ContentLanguage => "Content-Language".len(), + RfcHeader::ContentLocation => "Content-Location".len(), + RfcHeader::ContentTransferEncoding => "Content-Transfer-Encoding".len(), + RfcHeader::ContentType => "Content-Type".len(), + RfcHeader::ContentDisposition => "Content-Disposition".len(), + RfcHeader::ResentTo => "Resent-To".len(), + RfcHeader::ResentFrom => "Resent-From".len(), + RfcHeader::ResentBcc => "Resent-Bcc".len(), + RfcHeader::ResentCc => "Resent-Cc".len(), + RfcHeader::ResentSender => "Resent-Sender".len(), + RfcHeader::ResentDate => "Resent-Date".len(), + RfcHeader::ResentMessageId => "Resent-Message-ID".len(), + RfcHeader::ListArchive => "List-Archive".len(), + RfcHeader::ListHelp => "List-Help".len(), + RfcHeader::ListId => "List-ID".len(), + RfcHeader::ListOwner => "List-Owner".len(), + RfcHeader::ListPost => "List-Post".len(), + RfcHeader::ListSubscribe => "List-Subscribe".len(), + RfcHeader::ListUnsubscribe => "List-Unsubscribe".len(), + } + } + + /// Returns true if it is a MIME header. + pub fn is_mime_header(&self) -> bool { + matches!( + self, + RfcHeader::ContentDescription + | RfcHeader::ContentId + | RfcHeader::ContentLanguage + | RfcHeader::ContentLocation + | RfcHeader::ContentTransferEncoding + | RfcHeader::ContentType + | RfcHeader::ContentDisposition + ) + } + + pub fn is_empty(&self) -> bool { + false + } +} + +impl<'x> MimeHeaders<'x> for Message<'x> { + fn content_description(&self) -> Option<&str> { + self.parts[0] + .headers + .rfc(&RfcHeader::ContentDescription) + .and_then(|header| header.as_text()) + } + + fn content_disposition(&self) -> Option<&ContentType> { + self.parts[0] + .headers + .rfc(&RfcHeader::ContentDisposition) + .and_then(|header| header.as_content_type_ref()) + } + + fn content_id(&self) -> Option<&str> { + self.parts[0] + .headers + .rfc(&RfcHeader::ContentId) + .and_then(|header| header.as_text()) + } + + fn content_transfer_encoding(&self) -> Option<&str> { + self.parts[0] + .headers + .rfc(&RfcHeader::ContentTransferEncoding) + .and_then(|header| header.as_text()) + } + + fn content_type(&self) -> Option<&ContentType> { + self.parts[0] + .headers + .rfc(&RfcHeader::ContentType) + .and_then(|header| header.as_content_type_ref()) + } + + fn content_language(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ContentLanguage) + .unwrap_or(&HeaderValue::Empty) + } + + fn content_location(&self) -> Option<&str> { + self.parts[0] + .headers + .rfc(&RfcHeader::ContentLocation) + .and_then(|header| header.as_text()) + } +} + +impl<'x> MessagePart<'x> { + /// Returns the body part's contents as a `u8` slice + pub fn contents(&'x self) -> &'x [u8] { + match &self.body { + PartType::Text(text) | PartType::Html(text) => text.as_bytes(), + PartType::Binary(bin) | PartType::InlineBinary(bin) => bin.as_ref(), + PartType::Message(message) => message.raw_message.as_ref(), + PartType::Multipart(_) => b"", + } + } + + /// Returns the body part's contents as a `str` + pub fn text_contents(&'x self) -> Option<&'x str> { + match &self.body { + PartType::Text(text) | PartType::Html(text) => text.as_ref().into(), + PartType::Binary(bin) | PartType::InlineBinary(bin) => { + std::str::from_utf8(bin.as_ref()).ok() + } + PartType::Message(message) => std::str::from_utf8(message.raw_message.as_ref()).ok(), + PartType::Multipart(_) => None, + } + } + + /// Returns the nested message + pub fn message(&'x self) -> Option<&Message<'x>> { + if let PartType::Message(message) = &self.body { + Some(message) + } else { + None + } + } + + /// Returns the sub parts ids of a MIME part + pub fn sub_parts(&'x self) -> Option<&[MessagePartId]> { + if let PartType::Multipart(parts) = &self.body { + Some(parts.as_ref()) + } else { + None + } + } + + /// Returns the body part's length + pub fn len(&self) -> usize { + match &self.body { + PartType::Text(text) | PartType::Html(text) => text.len(), + PartType::Binary(bin) | PartType::InlineBinary(bin) => bin.len(), + PartType::Message(message) => message.raw_message.len(), + PartType::Multipart(_) => 0, + } + } + + /// Returns `true` when the body part MIME type is text/* + pub fn is_text(&self) -> bool { + matches!(self.body, PartType::Text(_) | PartType::Html(_)) + } + + /// Returns `true` when the body part MIME type is text/tml + pub fn is_text_html(&self) -> bool { + matches!(self.body, PartType::Html(_)) + } + + /// Returns `true` when the part is binary + pub fn is_binary(&self) -> bool { + matches!(self.body, PartType::Binary(_) | PartType::InlineBinary(_)) + } + + /// Returns `true` when the part is multipart + pub fn is_multipart(&self) -> bool { + matches!(self.body, PartType::Multipart(_)) + } + + /// Returns `true` when the part is a nested message + pub fn is_message(&self) -> bool { + matches!(self.body, PartType::Message(_)) + } + + /// Returns `true` when the body part is empty + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Get the message headers + pub fn headers(&self) -> &[Header] { + &self.headers + } + + /// Returns the body raw length + pub fn raw_len(&self) -> usize { + self.offset_end.saturating_sub(self.offset_header) + } + + /// Get the raw header offset of this part + pub fn raw_header_offset(&self) -> usize { + self.offset_header + } + + /// Get the raw body offset of this part + pub fn raw_body_offset(&self) -> usize { + self.offset_body + } + + /// Get the raw body end offset of this part + pub fn raw_end_offset(&self) -> usize { + self.offset_end + } + + /// Returns an owned version of the this part + pub fn into_owned(self) -> MessagePart<'static> { + MessagePart { + headers: self.headers.into_iter().map(|h| h.into_owned()).collect(), + is_encoding_problem: self.is_encoding_problem, + body: match self.body { + PartType::Text(v) => PartType::Text(v.into_owned().into()), + PartType::Html(v) => PartType::Html(v.into_owned().into()), + PartType::Binary(v) => PartType::Binary(v.into_owned().into()), + PartType::InlineBinary(v) => PartType::InlineBinary(v.into_owned().into()), + PartType::Message(v) => PartType::Message(v.into_owned()), + PartType::Multipart(v) => PartType::Multipart(v), + }, + encoding: self.encoding, + offset_header: self.offset_header, + offset_body: self.offset_body, + offset_end: self.offset_end, + } + } +} + +impl<'x> fmt::Display for MessagePart<'x> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(self.text_contents().unwrap_or("[no contents]")) + } +} + +impl<'x> MimeHeaders<'x> for MessagePart<'x> { + fn content_description(&self) -> Option<&str> { + self.headers + .rfc(&RfcHeader::ContentDescription) + .and_then(|header| header.as_text()) + } + + fn content_disposition(&self) -> Option<&ContentType> { + self.headers + .rfc(&RfcHeader::ContentDisposition) + .and_then(|header| header.as_content_type_ref()) + } + + fn content_id(&self) -> Option<&str> { + self.headers + .rfc(&RfcHeader::ContentId) + .and_then(|header| header.as_text()) + } + + fn content_transfer_encoding(&self) -> Option<&str> { + self.headers + .rfc(&RfcHeader::ContentTransferEncoding) + .and_then(|header| header.as_text()) + } + + fn content_type(&self) -> Option<&ContentType> { + self.headers + .rfc(&RfcHeader::ContentType) + .and_then(|header| header.as_content_type_ref()) + } + + fn content_language(&self) -> &HeaderValue { + self.headers + .rfc(&RfcHeader::ContentLanguage) + .unwrap_or(&HeaderValue::Empty) + } + + fn content_location(&self) -> Option<&str> { + self.headers + .rfc(&RfcHeader::ContentLocation) + .and_then(|header| header.as_text()) + } +} + +/// An RFC2047 Content-Type or RFC2183 Content-Disposition MIME header field. +impl<'x> ContentType<'x> { + /// Returns the type + pub fn ctype(&self) -> &str { + &self.c_type + } + + /// Returns the sub-type + pub fn subtype(&self) -> Option<&str> { + self.c_subtype.as_ref()?.as_ref().into() + } + + /// Returns an attribute by name + pub fn attribute(&self, name: &str) -> Option<&str> { + self.attributes + .as_ref()? + .iter() + .find(|(key, _)| key == name)? + .1 + .as_ref() + .into() + } + + /// Removes an attribute by name + pub fn remove_attribute(&mut self, name: &str) -> Option> { + let attributes = self.attributes.as_mut()?; + + attributes + .iter() + .position(|(key, _)| key == name) + .map(|pos| attributes.swap_remove(pos).1) + } + + /// Returns all attributes + pub fn attributes(&self) -> Option<&[(Cow, Cow)]> { + self.attributes.as_deref() + } + + /// Returns `true` when the provided attribute name is present + pub fn has_attribute(&self, name: &str) -> bool { + self.attributes + .as_ref() + .map_or_else(|| false, |attr| attr.iter().any(|(key, _)| key == name)) + } + + /// Returns ```true``` if the Content-Disposition type is "attachment" + pub fn is_attachment(&self) -> bool { + self.c_type.eq_ignore_ascii_case("attachment") + } + + /// Returns ```true``` if the Content-Disposition type is "inline" + pub fn is_inline(&self) -> bool { + self.c_type.eq_ignore_ascii_case("inline") + } +} + +/// A Received header +impl<'x> Received<'x> { + pub fn into_owned(self) -> Received<'static> { + Received { + from: self.from.map(|s| s.into_owned()), + from_ip: self.from_ip, + from_iprev: self.from_iprev.map(|s| s.into_owned().into()), + by: self.by.map(|s| s.into_owned()), + for_: self.for_.map(|s| s.into_owned().into()), + with: self.with, + tls_version: self.tls_version, + tls_cipher: self.tls_cipher.map(|s| s.into_owned().into()), + id: self.id.map(|s| s.into_owned().into()), + ident: self.ident.map(|s| s.into_owned().into()), + helo: self.helo.map(|s| s.into_owned()), + helo_cmd: self.helo_cmd, + via: self.via.map(|s| s.into_owned().into()), + date: self.date, + } + } +} + +/// A hostname or IP address. +impl<'x> Host<'x> { + pub fn into_owned(self) -> Host<'static> { + match self { + Host::Name(name) => Host::Name(name.into_owned().into()), + Host::IpAddr(ip) => Host::IpAddr(ip), + } + } +} + +impl<'x> GetHeader for Vec> { + fn rfc(&self, name: &RfcHeader) -> Option<&HeaderValue<'x>> { + self.iter() + .rev() + .find(|header| matches!(&header.name, HeaderName::Rfc(rfc_name) if rfc_name == name)) + .map(|header| &header.value) + } + + fn header(&self, name: &str) -> Option<&Header> { + self.iter() + .rev() + .find(|header| header.name.as_str().eq_ignore_ascii_case(name)) + } +} + +impl From for String { + fn from(header: RfcHeader) -> Self { + header.to_string() + } +} + +impl From for Cow<'_, str> { + fn from(header: RfcHeader) -> Self { + Cow::Borrowed(header.as_str()) + } +} + +impl From for i64 { + fn from(value: DateTime) -> Self { + value.to_timestamp() + } +} + +impl Display for RfcHeader { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/core/message.rs b/src/core/message.rs new file mode 100644 index 0000000..f3eb668 --- /dev/null +++ b/src/core/message.rs @@ -0,0 +1,489 @@ +/* + * Copyright Stalwart Labs Ltd. See the COPYING + * file at the top-level directory of this distribution. + * + * Licensed under the Apache License, Version 2.0 or the MIT license + * , at your + * option. This file may not be copied, modified, or distributed + * except according to those terms. + */ + +use std::{borrow::Cow, convert::TryInto}; + +use crate::{ + decoders::html::{html_to_text, text_to_html}, + parsers::{ + fields::thread::thread_name, + preview::{preview_html, preview_text}, + MessageStream, + }, + AttachmentIterator, BodyPartIterator, DateTime, GetHeader, Header, HeaderForm, HeaderName, + HeaderValue, Message, MessagePart, PartType, RfcHeader, +}; + +impl<'x> Message<'x> { + /// Returns the root message part + pub fn root_part(&self) -> &MessagePart<'x> { + &self.parts[0] + } + + /// Returns a parsed header. + pub fn header(&self, header: &str) -> Option<&HeaderValue> { + self.parts[0].headers.header(header).map(|h| &h.value) + } + + /// Removed a parsed header and returns its value. + pub fn remove_header(&mut self, header: &str) -> Option { + let headers = &mut self.parts[0].headers; + headers + .iter() + .position(|h| h.name.as_str() == header) + .map(|pos| headers.swap_remove(pos).value) + } + + /// Removed a parsed RFC heade and returns its value. + pub fn remove_header_rfc(&mut self, header: RfcHeader) -> Option { + let headers = &mut self.parts[0].headers; + headers + .iter() + .position(|h| matches!(&h.name, HeaderName::Rfc(header_name) if header_name == &header)) + .map(|pos| headers.swap_remove(pos).value) + } + + /// Returns the raw header. + pub fn header_raw(&self, header_name: &str) -> Option<&str> { + self.parts[0] + .headers + .header(header_name) + .and_then(|h| std::str::from_utf8(&self.raw_message[h.offset_start..h.offset_end]).ok()) + } + + // Parse a header as a specific type. + pub fn header_as(&self, header_name: &str, form: HeaderForm) -> Vec { + let mut results = Vec::new(); + for header in &self.parts[0].headers { + if header.name.as_str().eq_ignore_ascii_case(header_name) { + results.push( + self.raw_message + .get(header.offset_start..header.offset_end) + .map_or(HeaderValue::Empty, |bytes| match form { + HeaderForm::Raw => HeaderValue::Text( + std::str::from_utf8(bytes).unwrap_or_default().trim().into(), + ), + HeaderForm::Text => MessageStream::new(bytes).parse_unstructured(), + HeaderForm::Addresses => MessageStream::new(bytes).parse_address(), + HeaderForm::GroupedAddresses => { + MessageStream::new(bytes).parse_address() + } + HeaderForm::MessageIds => MessageStream::new(bytes).parse_id(), + HeaderForm::Date => MessageStream::new(bytes).parse_date(), + HeaderForm::URLs => MessageStream::new(bytes).parse_address(), + }), + ); + } + } + + results + } + + /// Returns an iterator over the RFC headers of this message. + pub fn headers(&self) -> &[Header] { + &self.parts[0].headers + } + + /// Returns an iterator over the matching RFC headers of this message. + pub fn header_values<'y: 'x>( + &'y self, + name: RfcHeader, + ) -> impl Iterator> { + self.parts[0].headers.iter().filter_map(move |header| { + if matches!(&header.name, HeaderName::Rfc(rfc_name) if rfc_name == &name) { + Some(&header.value) + } else { + None + } + }) + } + + /// Returns all headers in raw format + pub fn headers_raw(&self) -> impl Iterator { + self.parts[0].headers.iter().filter_map(move |header| { + Some(( + header.name.as_str(), + std::str::from_utf8(&self.raw_message[header.offset_start..header.offset_end]) + .ok()?, + )) + }) + } + + /// Returns the raw message + pub fn raw_message(&self) -> &[u8] { + let part = &self.parts[0]; + self.raw_message + .get(part.offset_header..part.offset_end) + .unwrap_or_default() + } + + /// Returns the BCC header field + pub fn bcc(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::Bcc) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the CC header field + pub fn cc(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::Cc) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all Comments header fields + pub fn comments(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::Comments) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Date header field + pub fn date(&self) -> Option<&DateTime> { + self.parts[0] + .headers + .rfc(&RfcHeader::Date) + .and_then(|header| header.as_datetime_ref()) + } + + /// Returns the From header field + pub fn from(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::From) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all In-Reply-To header fields + pub fn in_reply_to(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::InReplyTo) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all Keywords header fields + pub fn keywords(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::Keywords) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the List-Archive header field + pub fn list_archive(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ListArchive) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the List-Help header field + pub fn list_help(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ListHelp) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the List-ID header field + pub fn list_id(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ListId) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the List-Owner header field + pub fn list_owner(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ListOwner) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the List-Post header field + pub fn list_post(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ListPost) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the List-Subscribe header field + pub fn list_subscribe(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ListSubscribe) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the List-Unsubscribe header field + pub fn list_unsubscribe(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ListUnsubscribe) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Message-ID header field + pub fn message_id(&self) -> Option<&str> { + self.parts[0] + .headers + .rfc(&RfcHeader::MessageId) + .and_then(|header| header.as_text()) + } + + /// Returns the MIME-Version header field + pub fn mime_version(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::MimeVersion) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all Received header fields + pub fn received(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::Received) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all References header fields + pub fn references(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::References) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Reply-To header field + pub fn reply_to(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ReplyTo) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Resent-BCC header field + pub fn resent_bcc(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ResentBcc) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Resent-CC header field + pub fn resent_cc(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ResentTo) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all Resent-Date header fields + pub fn resent_date(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ResentDate) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Resent-From header field + pub fn resent_from(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ResentFrom) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all Resent-Message-ID header fields + pub fn resent_message_id(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ResentMessageId) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Sender header field + pub fn resent_sender(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ResentSender) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Resent-To header field + pub fn resent_to(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ResentTo) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns all Return-Path header fields + pub fn return_path(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::ReturnPath) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the return address from either the Return-Path + /// or From header fields + pub fn return_address(&self) -> Option<&str> { + match self.parts[0].headers.rfc(&RfcHeader::ReturnPath) { + Some(HeaderValue::Text(text)) => Some(text.as_ref()), + Some(HeaderValue::TextList(text_list)) => text_list.last().map(|t| t.as_ref()), + _ => match self.parts[0].headers.rfc(&RfcHeader::From) { + Some(HeaderValue::Address(addr)) => addr.address.as_deref(), + Some(HeaderValue::AddressList(addr_list)) => { + addr_list.last().and_then(|a| a.address.as_deref()) + } + _ => None, + }, + } + } + + /// Returns the Sender header field + pub fn sender(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::Sender) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns the Subject header field + pub fn subject(&self) -> Option<&str> { + self.parts[0] + .headers + .rfc(&RfcHeader::Subject) + .and_then(|header| header.as_text()) + } + + /// Returns the message thread name or 'base subject' as defined in + /// [RFC 5957 - Internet Message Access Protocol - SORT and THREAD Extensions (Section 2.1)](https://datatracker.ietf.org/doc/html/rfc5256#section-2.1) + pub fn thread_name(&self) -> Option<&str> { + thread_name(self.subject()?).into() + } + + /// Returns the To header field + pub fn to(&self) -> &HeaderValue { + self.parts[0] + .headers + .rfc(&RfcHeader::To) + .unwrap_or(&HeaderValue::Empty) + } + + /// Returns a preview of the message body + pub fn body_preview(&self, preview_len: usize) -> Option> { + if !self.text_body.is_empty() { + preview_text(self.body_text(0)?, preview_len).into() + } else if !self.html_body.is_empty() { + preview_html(self.body_html(0)?, preview_len).into() + } else { + None + } + } + + /// Returns a message body part as text/plain + pub fn body_html(&'x self, pos: usize) -> Option> { + let part = self.parts.get(*self.html_body.get(pos)?)?; + match &part.body { + PartType::Html(html) => Some(html.as_ref().into()), + PartType::Text(text) => Some(text_to_html(text.as_ref()).into()), + _ => None, + } + } + + /// Returns a message body part as text/plain + pub fn body_text(&'x self, pos: usize) -> Option> { + let part = self.parts.get(*self.text_body.get(pos)?)?; + match &part.body { + PartType::Text(text) => Some(text.as_ref().into()), + PartType::Html(html) => Some(html_to_text(html.as_ref()).into()), + _ => None, + } + } + + /// Returns a message part by position + pub fn part(&self, pos: usize) -> Option<&MessagePart> { + self.parts.get(pos) + } + + /// Returns an inline HTML body part by position + pub fn html_part(&self, pos: usize) -> Option<&MessagePart> { + self.parts.get(*self.html_body.get(pos)?) + } + + /// Returns an inline text body part by position + pub fn text_part(&self, pos: usize) -> Option<&MessagePart> { + self.parts.get(*self.text_body.get(pos)?) + } + + /// Returns an attacment by position + pub fn attachment(&self, pos: usize) -> Option<&MessagePart<'x>> { + self.parts.get(*self.attachments.get(pos)?) + } + + /// Returns the number of plain text body parts + pub fn text_body_count(&self) -> usize { + self.text_body.len() + } + + /// Returns the number of HTML body parts + pub fn html_body_count(&self) -> usize { + self.html_body.len() + } + + /// Returns the number of attachments + pub fn attachment_count(&self) -> usize { + self.attachments.len() + } + + /// Returns an Interator over the text body parts + pub fn text_bodies(&'x self) -> BodyPartIterator<'x> { + BodyPartIterator::new(self, &self.text_body) + } + + /// Returns an Interator over the HTML body parts + pub fn html_bodies(&'x self) -> BodyPartIterator<'x> { + BodyPartIterator::new(self, &self.html_body) + } + + /// Returns an Interator over the attachments + pub fn attachments(&'x self) -> AttachmentIterator<'x> { + AttachmentIterator::new(self) + } + + /// Returns an owned version of the message + pub fn into_owned(self) -> Message<'static> { + Message { + html_body: self.html_body, + text_body: self.text_body, + attachments: self.attachments, + parts: self.parts.into_iter().map(|p| p.into_owned()).collect(), + raw_message: self.raw_message.into_owned().into(), + } + } +} + +impl<'x> TryInto> for &'x [u8] { + type Error = (); + + fn try_into(self) -> Result, Self::Error> { + Message::parse(self).ok_or(()) + } +} diff --git a/src/core/mod.rs b/src/core/mod.rs new file mode 100644 index 0000000..cf7e1b8 --- /dev/null +++ b/src/core/mod.rs @@ -0,0 +1,15 @@ +/* + * Copyright Stalwart Labs Ltd. See the COPYING + * file at the top-level directory of this distribution. + * + * Licensed under the Apache License, Version 2.0 or the MIT license + * , at your + * option. This file may not be copied, modified, or distributed + * except according to those terms. + */ + +pub mod address; +pub mod body; +pub mod header; +pub mod message; diff --git a/src/lib.rs b/src/lib.rs index 9a78b5c..0f36980 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -248,23 +248,13 @@ //! println!("{}", serde_json::to_string_pretty(&message).unwrap()); //! println!("{}", serde_yaml::to_string(&message).unwrap()); //!``` +pub mod core; pub mod decoders; pub mod mailbox; pub mod parsers; -use std::{ - borrow::Cow, - convert::TryInto, - fmt::{self, Display}, - hash::Hash, -}; +use std::{borrow::Cow, hash::Hash, net::IpAddr}; -use decoders::html::{html_to_text, text_to_html}; -use parsers::{ - fields::thread::thread_name, - preview::{preview_html, preview_text}, - MessageStream, -}; #[cfg(feature = "serde_support")] use serde::{Deserialize, Serialize}; @@ -378,22 +368,6 @@ pub struct Addr<'x> { pub address: Option>, } -impl<'x> Addr<'x> { - pub fn new(name: Option<&'x str>, address: &'x str) -> Self { - Self { - name: name.map(|name| name.into()), - address: Some(address.into()), - } - } - - pub fn into_owned(self) -> Addr<'static> { - Addr { - name: self.name.map(|s| s.into_owned().into()), - address: self.address.map(|s| s.into_owned().into()), - } - } -} - /// An RFC5322 address group. #[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] @@ -407,22 +381,6 @@ pub struct Group<'x> { pub addresses: Vec>, } -impl<'x> Group<'x> { - pub fn new(name: &'x str, addresses: Vec>) -> Self { - Self { - name: Some(name.into()), - addresses, - } - } - - pub fn into_owned(self) -> Group<'static> { - Group { - name: self.name.map(|s| s.into_owned().into()), - addresses: self.addresses.into_iter().map(|a| a.into_owned()).collect(), - } - } -} - /// A message header. #[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] @@ -434,44 +392,6 @@ pub struct Header<'x> { pub offset_end: usize, } -impl<'x> Header<'x> { - /// Returns the header name - pub fn name(&self) -> &str { - self.name.as_str() - } - - /// Returns the parsed header value - pub fn value(&self) -> &HeaderValue { - &self.value - } - - /// Returns the raw offset start - pub fn offset_start(&self) -> usize { - self.offset_start - } - - /// Returns the raw offset end - pub fn offset_end(&self) -> usize { - self.offset_end - } - - /// Returns the raw offset of the header name - pub fn offset_field(&self) -> usize { - self.offset_field - } - - /// Returns an owned version of the header - pub fn into_owned(self) -> Header<'static> { - Header { - name: self.name.into_owned(), - value: self.value.into_owned(), - offset_field: self.offset_field, - offset_start: self.offset_start, - offset_end: self.offset_end, - } - } -} - #[derive(Debug, Clone)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] pub enum HeaderName<'x> { @@ -479,81 +399,6 @@ pub enum HeaderName<'x> { Other(Cow<'x, str>), } -impl PartialEq for HeaderName<'_> { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::Rfc(a), Self::Rfc(b)) => a == b, - (Self::Other(a), Self::Other(b)) => a.eq_ignore_ascii_case(b), - _ => false, - } - } -} - -impl<'x> Hash for HeaderName<'x> { - fn hash(&self, state: &mut H) { - match self { - HeaderName::Rfc(rfc) => rfc.hash(state), - HeaderName::Other(value) => { - for ch in value.as_bytes() { - ch.to_ascii_lowercase().hash(state) - } - } - } - } -} - -impl Eq for HeaderName<'_> {} - -impl<'x> HeaderName<'x> { - pub fn as_str(&self) -> &str { - match self { - HeaderName::Rfc(header) => header.as_str(), - HeaderName::Other(name) => name.as_ref(), - } - } - - pub fn to_owned(&self) -> HeaderName<'static> { - match self { - HeaderName::Rfc(header) => HeaderName::Rfc(*header), - HeaderName::Other(name) => HeaderName::Other(name.clone().into_owned().into()), - } - } - - pub fn into_owned(self) -> HeaderName<'static> { - match self { - HeaderName::Rfc(header) => HeaderName::Rfc(header), - HeaderName::Other(name) => HeaderName::Other(name.into_owned().into()), - } - } - - pub fn unwrap(self) -> String { - match self { - HeaderName::Rfc(header) => header.as_str().to_owned(), - HeaderName::Other(name) => name.into_owned(), - } - } - - /// Returns true if it is a MIME header. - pub fn is_mime_header(&self) -> bool { - match self { - HeaderName::Rfc(header) => header.is_mime_header(), - HeaderName::Other(_) => false, - } - } - - /// Returns the lenght of the header - pub fn len(&self) -> usize { - match self { - HeaderName::Rfc(name) => name.len(), - HeaderName::Other(name) => name.len(), - } - } - - pub fn is_empty(&self) -> bool { - false - } -} - /// A header field #[repr(u8)] #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, PartialOrd, Ord)] @@ -599,116 +444,6 @@ pub enum RfcHeader { ListUnsubscribe = 36, } // Note: Do not add new entries without updating HDR* tables -impl RfcHeader { - pub fn as_str(&self) -> &'static str { - match self { - RfcHeader::Subject => "Subject", - RfcHeader::From => "From", - RfcHeader::To => "To", - RfcHeader::Cc => "Cc", - RfcHeader::Date => "Date", - RfcHeader::Bcc => "Bcc", - RfcHeader::ReplyTo => "Reply-To", - RfcHeader::Sender => "Sender", - RfcHeader::Comments => "Comments", - RfcHeader::InReplyTo => "In-Reply-To", - RfcHeader::Keywords => "Keywords", - RfcHeader::Received => "Received", - RfcHeader::MessageId => "Message-ID", - RfcHeader::References => "References", - RfcHeader::ReturnPath => "Return-Path", - RfcHeader::MimeVersion => "MIME-Version", - RfcHeader::ContentDescription => "Content-Description", - RfcHeader::ContentId => "Content-ID", - RfcHeader::ContentLanguage => "Content-Language", - RfcHeader::ContentLocation => "Content-Location", - RfcHeader::ContentTransferEncoding => "Content-Transfer-Encoding", - RfcHeader::ContentType => "Content-Type", - RfcHeader::ContentDisposition => "Content-Disposition", - RfcHeader::ResentTo => "Resent-To", - RfcHeader::ResentFrom => "Resent-From", - RfcHeader::ResentBcc => "Resent-Bcc", - RfcHeader::ResentCc => "Resent-Cc", - RfcHeader::ResentSender => "Resent-Sender", - RfcHeader::ResentDate => "Resent-Date", - RfcHeader::ResentMessageId => "Resent-Message-ID", - RfcHeader::ListArchive => "List-Archive", - RfcHeader::ListHelp => "List-Help", - RfcHeader::ListId => "List-ID", - RfcHeader::ListOwner => "List-Owner", - RfcHeader::ListPost => "List-Post", - RfcHeader::ListSubscribe => "List-Subscribe", - RfcHeader::ListUnsubscribe => "List-Unsubscribe", - } - } - - pub fn len(&self) -> usize { - match self { - RfcHeader::Subject => "Subject".len(), - RfcHeader::From => "From".len(), - RfcHeader::To => "To".len(), - RfcHeader::Cc => "Cc".len(), - RfcHeader::Date => "Date".len(), - RfcHeader::Bcc => "Bcc".len(), - RfcHeader::ReplyTo => "Reply-To".len(), - RfcHeader::Sender => "Sender".len(), - RfcHeader::Comments => "Comments".len(), - RfcHeader::InReplyTo => "In-Reply-To".len(), - RfcHeader::Keywords => "Keywords".len(), - RfcHeader::Received => "Received".len(), - RfcHeader::MessageId => "Message-ID".len(), - RfcHeader::References => "References".len(), - RfcHeader::ReturnPath => "Return-Path".len(), - RfcHeader::MimeVersion => "MIME-Version".len(), - RfcHeader::ContentDescription => "Content-Description".len(), - RfcHeader::ContentId => "Content-ID".len(), - RfcHeader::ContentLanguage => "Content-Language".len(), - RfcHeader::ContentLocation => "Content-Location".len(), - RfcHeader::ContentTransferEncoding => "Content-Transfer-Encoding".len(), - RfcHeader::ContentType => "Content-Type".len(), - RfcHeader::ContentDisposition => "Content-Disposition".len(), - RfcHeader::ResentTo => "Resent-To".len(), - RfcHeader::ResentFrom => "Resent-From".len(), - RfcHeader::ResentBcc => "Resent-Bcc".len(), - RfcHeader::ResentCc => "Resent-Cc".len(), - RfcHeader::ResentSender => "Resent-Sender".len(), - RfcHeader::ResentDate => "Resent-Date".len(), - RfcHeader::ResentMessageId => "Resent-Message-ID".len(), - RfcHeader::ListArchive => "List-Archive".len(), - RfcHeader::ListHelp => "List-Help".len(), - RfcHeader::ListId => "List-ID".len(), - RfcHeader::ListOwner => "List-Owner".len(), - RfcHeader::ListPost => "List-Post".len(), - RfcHeader::ListSubscribe => "List-Subscribe".len(), - RfcHeader::ListUnsubscribe => "List-Unsubscribe".len(), - } - } - - /// Returns true if it is a MIME header. - pub fn is_mime_header(&self) -> bool { - matches!( - self, - RfcHeader::ContentDescription - | RfcHeader::ContentId - | RfcHeader::ContentLanguage - | RfcHeader::ContentLocation - | RfcHeader::ContentTransferEncoding - | RfcHeader::ContentType - | RfcHeader::ContentDisposition - ) - } - - pub fn is_empty(&self) -> bool { - false - } -} - -impl Display for RfcHeader { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.as_str()) - } -} - /// Parsed header value. #[derive(Debug, PartialEq, Eq, Clone, Default)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] @@ -737,6 +472,9 @@ pub enum HeaderValue<'x> { /// Content-Type or Content-Disposition header ContentType(ContentType<'x>), + /// Received header + Received(Box>), + #[default] Empty, } @@ -752,147 +490,6 @@ pub enum HeaderForm { Date, URLs, } - -impl<'x> HeaderValue<'x> { - pub fn is_empty(&self) -> bool { - *self == HeaderValue::Empty - } - - pub fn unwrap_text(self) -> Cow<'x, str> { - match self { - HeaderValue::Text(s) => s, - _ => panic!("HeaderValue::unwrap_text called on non-Text value"), - } - } - - pub fn unwrap_datetime(self) -> DateTime { - match self { - HeaderValue::DateTime(d) => d, - _ => panic!("HeaderValue::unwrap_datetime called on non-DateTime value"), - } - } - - pub fn unwrap_content_type(self) -> ContentType<'x> { - match self { - HeaderValue::ContentType(c) => c, - _ => panic!("HeaderValue::unwrap_content_type called on non-ContentType value"), - } - } - - pub fn as_text_ref(&self) -> Option<&str> { - match *self { - HeaderValue::Text(ref s) => Some(s), - HeaderValue::TextList(ref l) => l.last()?.as_ref().into(), - _ => None, - } - } - - pub fn as_text_list(&self) -> Option> { - match *self { - HeaderValue::Text(ref s) => Some(vec![s.as_ref()]), - HeaderValue::TextList(ref l) => Some(l.iter().map(|l| l.as_ref()).collect()), - _ => None, - } - } - - pub fn content_type(&self) -> &ContentType<'x> { - match *self { - HeaderValue::ContentType(ref ct) => ct, - _ => panic!( - "HeaderValue::content_type called on non-ContentType: {:?}", - self - ), - } - } - - pub fn as_content_type_ref(&self) -> Option<&ContentType> { - match *self { - HeaderValue::ContentType(ref c) => Some(c), - _ => None, - } - } - - pub fn as_datetime_ref(&self) -> Option<&DateTime> { - match *self { - HeaderValue::DateTime(ref d) => Some(d), - _ => None, - } - } - - pub fn into_owned(self) -> HeaderValue<'static> { - match self { - HeaderValue::Address(addr) => HeaderValue::Address(addr.into_owned()), - HeaderValue::AddressList(list) => { - HeaderValue::AddressList(list.into_iter().map(|addr| addr.into_owned()).collect()) - } - HeaderValue::Group(group) => HeaderValue::Group(group.into_owned()), - HeaderValue::GroupList(list) => { - HeaderValue::GroupList(list.into_iter().map(|group| group.into_owned()).collect()) - } - HeaderValue::Text(text) => HeaderValue::Text(text.into_owned().into()), - HeaderValue::TextList(list) => HeaderValue::TextList( - list.into_iter() - .map(|text| text.into_owned().into()) - .collect(), - ), - HeaderValue::DateTime(datetime) => HeaderValue::DateTime(datetime), - HeaderValue::ContentType(ct) => HeaderValue::ContentType(ContentType { - c_type: ct.c_type.into_owned().into(), - c_subtype: ct.c_subtype.map(|s| s.into_owned().into()), - attributes: ct.attributes.map(|attributes| { - attributes - .into_iter() - .map(|(k, v)| (k.into_owned().into(), v.into_owned().into())) - .collect() - }), - }), - HeaderValue::Empty => HeaderValue::Empty, - } - } - - pub fn len(&self) -> usize { - match self { - HeaderValue::Text(text) => text.len(), - HeaderValue::TextList(list) => list.iter().map(|t| t.len()).sum(), - HeaderValue::Address(a) => { - a.name.as_ref().map_or(0, |a| a.len()) + a.address.as_ref().map_or(0, |a| a.len()) - } - HeaderValue::AddressList(list) => list - .iter() - .map(|a| { - a.name.as_ref().map_or(0, |a| a.len()) - + a.address.as_ref().map_or(0, |a| a.len()) - }) - .sum(), - HeaderValue::Group(group) => group - .addresses - .iter() - .map(|a| { - a.name.as_ref().map_or(0, |a| a.len()) - + a.address.as_ref().map_or(0, |a| a.len()) - }) - .sum(), - HeaderValue::GroupList(grouplist) => grouplist - .iter() - .flat_map(|g| g.addresses.iter()) - .map(|a| { - a.name.as_ref().map_or(0, |a| a.len()) - + a.address.as_ref().map_or(0, |a| a.len()) - }) - .sum(), - HeaderValue::DateTime(_) => 24, - HeaderValue::ContentType(ct) => { - ct.c_type.len() - + ct.c_subtype.as_ref().map_or(0, |s| s.len()) - + ct.attributes - .as_ref() - .map_or(0, |at| at.iter().map(|(a, b)| a.len() + b.len()).sum()) - } - HeaderValue::Empty => 0, - } - } -} - /// An RFC2047 Content-Type or RFC2183 Content-Disposition MIME header field. #[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] @@ -919,462 +516,148 @@ pub struct DateTime { pub tz_minute: u8, } -impl<'x> Message<'x> { - /// Returns the root message part - pub fn root_part(&self) -> &MessagePart<'x> { - &self.parts[0] - } +#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] +pub struct Received<'x> { + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + from: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + from_ip: Option, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + from_iprev: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + by: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + for_: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + with: Option, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + tls_version: Option, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + tls_cipher: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none") + )] + id: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + ident: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + helo: Option>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + helo_cmd: Option, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "Option::is_none"), + serde(default) + )] + via: Option>, + date: Option, +} - /// Returns a parsed header. - pub fn header(&self, header: &str) -> Option<&HeaderValue> { - self.parts[0].headers.header(header).map(|h| &h.value) - } +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] +pub enum Host<'x> { + Name(Cow<'x, str>), + IpAddr(IpAddr), +} - /// Removed a parsed header and returns its value. - pub fn remove_header(&mut self, header: &str) -> Option { - let headers = &mut self.parts[0].headers; - headers - .iter() - .position(|h| h.name.as_str() == header) - .map(|pos| headers.swap_remove(pos).value) - } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] +enum TlsVersion { + SSLv2, + SSLv3, + TLSv1_0, + TLSv1_1, + TLSv1_2, + TLSv1_3, + DTLSv1_0, + DTLSv1_2, + DTLSv1_3, +} - /// Removed a parsed RFC heade and returns its value. - pub fn remove_header_rfc(&mut self, header: RfcHeader) -> Option { - let headers = &mut self.parts[0].headers; - headers - .iter() - .position(|h| matches!(&h.name, HeaderName::Rfc(header_name) if header_name == &header)) - .map(|pos| headers.swap_remove(pos).value) - } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] +enum Greeting { + Helo, + Ehlo, + Lhlo, +} - /// Returns the raw header. - pub fn header_raw(&self, header_name: &str) -> Option<&str> { - self.parts[0] - .headers - .header(header_name) - .and_then(|h| std::str::from_utf8(&self.raw_message[h.offset_start..h.offset_end]).ok()) - } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] +#[allow(clippy::upper_case_acronyms)] +enum Protocol { + // IANA Mail Transmission Types + SMTP, + ESMTP, + ESMTPA, + ESMTPS, + ESMTPSA, + LMTP, + LMTPA, + LMTPS, + LMTPSA, + MMS, + UTF8SMTP, + UTF8SMTPA, + UTF8SMTPS, + UTF8SMTPSA, + UTF8LMTP, + UTF8LMTPA, + UTF8LMTPS, + UTF8LMTPSA, - // Parse a header as a specific type. - pub fn header_as(&self, header_name: &str, form: HeaderForm) -> Vec { - let mut results = Vec::new(); - for header in &self.parts[0].headers { - if header.name.as_str().eq_ignore_ascii_case(header_name) { - results.push( - self.raw_message - .get(header.offset_start..header.offset_end) - .map_or(HeaderValue::Empty, |bytes| match form { - HeaderForm::Raw => HeaderValue::Text( - std::str::from_utf8(bytes).unwrap_or_default().trim().into(), - ), - HeaderForm::Text => MessageStream::new(bytes).parse_unstructured(), - HeaderForm::Addresses => MessageStream::new(bytes).parse_address(), - HeaderForm::GroupedAddresses => { - MessageStream::new(bytes).parse_address() - } - HeaderForm::MessageIds => MessageStream::new(bytes).parse_id(), - HeaderForm::Date => MessageStream::new(bytes).parse_date(), - HeaderForm::URLs => MessageStream::new(bytes).parse_address(), - }), - ); - } - } - - results - } - - /// Returns an iterator over the RFC headers of this message. - pub fn headers(&self) -> &[Header] { - &self.parts[0].headers - } - - /// Returns an iterator over the matching RFC headers of this message. - pub fn header_values<'y: 'x>( - &'y self, - name: RfcHeader, - ) -> impl Iterator> { - self.parts[0].headers.iter().filter_map(move |header| { - if matches!(&header.name, HeaderName::Rfc(rfc_name) if rfc_name == &name) { - Some(&header.value) - } else { - None - } - }) - } - - /// Returns all headers in raw format - pub fn headers_raw(&self) -> impl Iterator { - self.parts[0].headers.iter().filter_map(move |header| { - Some(( - header.name.as_str(), - std::str::from_utf8(&self.raw_message[header.offset_start..header.offset_end]) - .ok()?, - )) - }) - } - - /// Returns the raw message - pub fn raw_message(&self) -> &[u8] { - let part = &self.parts[0]; - self.raw_message - .get(part.offset_header..part.offset_end) - .unwrap_or_default() - } - - /// Returns the BCC header field - pub fn bcc(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::Bcc) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the CC header field - pub fn cc(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::Cc) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all Comments header fields - pub fn comments(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::Comments) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Date header field - pub fn date(&self) -> Option<&DateTime> { - self.parts[0] - .headers - .rfc(&RfcHeader::Date) - .and_then(|header| header.as_datetime_ref()) - } - - /// Returns the From header field - pub fn from(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::From) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all In-Reply-To header fields - pub fn in_reply_to(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::InReplyTo) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all Keywords header fields - pub fn keywords(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::Keywords) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the List-Archive header field - pub fn list_archive(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ListArchive) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the List-Help header field - pub fn list_help(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ListHelp) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the List-ID header field - pub fn list_id(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ListId) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the List-Owner header field - pub fn list_owner(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ListOwner) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the List-Post header field - pub fn list_post(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ListPost) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the List-Subscribe header field - pub fn list_subscribe(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ListSubscribe) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the List-Unsubscribe header field - pub fn list_unsubscribe(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ListUnsubscribe) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Message-ID header field - pub fn message_id(&self) -> Option<&str> { - self.parts[0] - .headers - .rfc(&RfcHeader::MessageId) - .and_then(|header| header.as_text_ref()) - } - - /// Returns the MIME-Version header field - pub fn mime_version(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::MimeVersion) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all Received header fields - pub fn received(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::Received) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all References header fields - pub fn references(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::References) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Reply-To header field - pub fn reply_to(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ReplyTo) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Resent-BCC header field - pub fn resent_bcc(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ResentBcc) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Resent-CC header field - pub fn resent_cc(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ResentTo) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all Resent-Date header fields - pub fn resent_date(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ResentDate) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Resent-From header field - pub fn resent_from(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ResentFrom) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all Resent-Message-ID header fields - pub fn resent_message_id(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ResentMessageId) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Sender header field - pub fn resent_sender(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ResentSender) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Resent-To header field - pub fn resent_to(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ResentTo) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns all Return-Path header fields - pub fn return_path(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ReturnPath) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the return address from either the Return-Path - /// or From header fields - pub fn return_address(&self) -> Option<&str> { - match self.parts[0].headers.rfc(&RfcHeader::ReturnPath) { - Some(HeaderValue::Text(text)) => Some(text.as_ref()), - Some(HeaderValue::TextList(text_list)) => text_list.last().map(|t| t.as_ref()), - _ => match self.parts[0].headers.rfc(&RfcHeader::From) { - Some(HeaderValue::Address(addr)) => addr.address.as_deref(), - Some(HeaderValue::AddressList(addr_list)) => { - addr_list.last().and_then(|a| a.address.as_deref()) - } - _ => None, - }, - } - } - - /// Returns the Sender header field - pub fn sender(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::Sender) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns the Subject header field - pub fn subject(&self) -> Option<&str> { - self.parts[0] - .headers - .rfc(&RfcHeader::Subject) - .and_then(|header| header.as_text_ref()) - } - - /// Returns the message thread name or 'base subject' as defined in - /// [RFC 5957 - Internet Message Access Protocol - SORT and THREAD Extensions (Section 2.1)](https://datatracker.ietf.org/doc/html/rfc5256#section-2.1) - pub fn thread_name(&self) -> Option<&str> { - thread_name(self.subject()?).into() - } - - /// Returns the To header field - pub fn to(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::To) - .unwrap_or(&HeaderValue::Empty) - } - - /// Returns a preview of the message body - pub fn body_preview(&self, preview_len: usize) -> Option> { - if !self.text_body.is_empty() { - preview_text(self.body_text(0)?, preview_len).into() - } else if !self.html_body.is_empty() { - preview_html(self.body_html(0)?, preview_len).into() - } else { - None - } - } - - /// Returns a message body part as text/plain - pub fn body_html(&'x self, pos: usize) -> Option> { - let part = self.parts.get(*self.html_body.get(pos)?)?; - match &part.body { - PartType::Html(html) => Some(html.as_ref().into()), - PartType::Text(text) => Some(text_to_html(text.as_ref()).into()), - _ => None, - } - } - - /// Returns a message body part as text/plain - pub fn body_text(&'x self, pos: usize) -> Option> { - let part = self.parts.get(*self.text_body.get(pos)?)?; - match &part.body { - PartType::Text(text) => Some(text.as_ref().into()), - PartType::Html(html) => Some(html_to_text(html.as_ref()).into()), - _ => None, - } - } - - /// Returns a message part by position - pub fn part(&self, pos: usize) -> Option<&MessagePart> { - self.parts.get(pos) - } - - /// Returns an inline HTML body part by position - pub fn html_part(&self, pos: usize) -> Option<&MessagePart> { - self.parts.get(*self.html_body.get(pos)?) - } - - /// Returns an inline text body part by position - pub fn text_part(&self, pos: usize) -> Option<&MessagePart> { - self.parts.get(*self.text_body.get(pos)?) - } - - /// Returns an attacment by position - pub fn attachment(&self, pos: usize) -> Option<&MessagePart<'x>> { - self.parts.get(*self.attachments.get(pos)?) - } - - /// Returns the number of plain text body parts - pub fn text_body_count(&self) -> usize { - self.text_body.len() - } - - /// Returns the number of HTML body parts - pub fn html_body_count(&self) -> usize { - self.html_body.len() - } - - /// Returns the number of attachments - pub fn attachment_count(&self) -> usize { - self.attachments.len() - } - - /// Returns an Interator over the text body parts - pub fn text_bodies(&'x self) -> BodyPartIterator<'x> { - BodyPartIterator::new(self, &self.text_body) - } - - /// Returns an Interator over the HTML body parts - pub fn html_bodies(&'x self) -> BodyPartIterator<'x> { - BodyPartIterator::new(self, &self.html_body) - } - - /// Returns an Interator over the attachments - pub fn attachments(&'x self) -> AttachmentIterator<'x> { - AttachmentIterator::new(self) - } - - /// Returns an owned version of the message - pub fn into_owned(self) -> Message<'static> { - Message { - html_body: self.html_body, - text_body: self.text_body, - attachments: self.attachments, - parts: self.parts.into_iter().map(|p| p.into_owned()).collect(), - raw_message: self.raw_message.into_owned().into(), - } - } + // Non-Standard Mail Transmission Types + HTTP, + HTTPS, + IMAP, + POP3, + Local, // includes stdin, socket, etc. } /// MIME Header field access trait @@ -1411,254 +694,11 @@ pub trait MimeHeaders<'x> { } } -impl<'x> MimeHeaders<'x> for Message<'x> { - fn content_description(&self) -> Option<&str> { - self.parts[0] - .headers - .rfc(&RfcHeader::ContentDescription) - .and_then(|header| header.as_text_ref()) - } - - fn content_disposition(&self) -> Option<&ContentType> { - self.parts[0] - .headers - .rfc(&RfcHeader::ContentDisposition) - .and_then(|header| header.as_content_type_ref()) - } - - fn content_id(&self) -> Option<&str> { - self.parts[0] - .headers - .rfc(&RfcHeader::ContentId) - .and_then(|header| header.as_text_ref()) - } - - fn content_transfer_encoding(&self) -> Option<&str> { - self.parts[0] - .headers - .rfc(&RfcHeader::ContentTransferEncoding) - .and_then(|header| header.as_text_ref()) - } - - fn content_type(&self) -> Option<&ContentType> { - self.parts[0] - .headers - .rfc(&RfcHeader::ContentType) - .and_then(|header| header.as_content_type_ref()) - } - - fn content_language(&self) -> &HeaderValue { - self.parts[0] - .headers - .rfc(&RfcHeader::ContentLanguage) - .unwrap_or(&HeaderValue::Empty) - } - - fn content_location(&self) -> Option<&str> { - self.parts[0] - .headers - .rfc(&RfcHeader::ContentLocation) - .and_then(|header| header.as_text_ref()) - } -} - -impl<'x> MessagePart<'x> { - /// Returns the body part's contents as a `u8` slice - pub fn contents(&'x self) -> &'x [u8] { - match &self.body { - PartType::Text(text) | PartType::Html(text) => text.as_bytes(), - PartType::Binary(bin) | PartType::InlineBinary(bin) => bin.as_ref(), - PartType::Message(message) => message.raw_message.as_ref(), - PartType::Multipart(_) => b"", - } - } - - /// Returns the body part's contents as a `str` - pub fn text_contents(&'x self) -> Option<&'x str> { - match &self.body { - PartType::Text(text) | PartType::Html(text) => text.as_ref().into(), - PartType::Binary(bin) | PartType::InlineBinary(bin) => { - std::str::from_utf8(bin.as_ref()).ok() - } - PartType::Message(message) => std::str::from_utf8(message.raw_message.as_ref()).ok(), - PartType::Multipart(_) => None, - } - } - - /// Returns the nested message - pub fn message(&'x self) -> Option<&Message<'x>> { - if let PartType::Message(message) = &self.body { - Some(message) - } else { - None - } - } - - /// Returns the sub parts ids of a MIME part - pub fn sub_parts(&'x self) -> Option<&[MessagePartId]> { - if let PartType::Multipart(parts) = &self.body { - Some(parts.as_ref()) - } else { - None - } - } - - /// Returns the body part's length - pub fn len(&self) -> usize { - match &self.body { - PartType::Text(text) | PartType::Html(text) => text.len(), - PartType::Binary(bin) | PartType::InlineBinary(bin) => bin.len(), - PartType::Message(message) => message.raw_message.len(), - PartType::Multipart(_) => 0, - } - } - - /// Returns `true` when the body part MIME type is text/* - pub fn is_text(&self) -> bool { - matches!(self.body, PartType::Text(_) | PartType::Html(_)) - } - - /// Returns `true` when the body part MIME type is text/tml - pub fn is_text_html(&self) -> bool { - matches!(self.body, PartType::Html(_)) - } - - /// Returns `true` when the part is binary - pub fn is_binary(&self) -> bool { - matches!(self.body, PartType::Binary(_) | PartType::InlineBinary(_)) - } - - /// Returns `true` when the part is multipart - pub fn is_multipart(&self) -> bool { - matches!(self.body, PartType::Multipart(_)) - } - - /// Returns `true` when the part is a nested message - pub fn is_message(&self) -> bool { - matches!(self.body, PartType::Message(_)) - } - - /// Returns `true` when the body part is empty - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - - /// Get the message headers - pub fn headers(&self) -> &[Header] { - &self.headers - } - - /// Returns the body raw length - pub fn raw_len(&self) -> usize { - self.offset_end.saturating_sub(self.offset_header) - } - - /// Get the raw header offset of this part - pub fn raw_header_offset(&self) -> usize { - self.offset_header - } - - /// Get the raw body offset of this part - pub fn raw_body_offset(&self) -> usize { - self.offset_body - } - - /// Get the raw body end offset of this part - pub fn raw_end_offset(&self) -> usize { - self.offset_end - } - - /// Returns an owned version of the this part - pub fn into_owned(self) -> MessagePart<'static> { - MessagePart { - headers: self.headers.into_iter().map(|h| h.into_owned()).collect(), - is_encoding_problem: self.is_encoding_problem, - body: match self.body { - PartType::Text(v) => PartType::Text(v.into_owned().into()), - PartType::Html(v) => PartType::Html(v.into_owned().into()), - PartType::Binary(v) => PartType::Binary(v.into_owned().into()), - PartType::InlineBinary(v) => PartType::InlineBinary(v.into_owned().into()), - PartType::Message(v) => PartType::Message(v.into_owned()), - PartType::Multipart(v) => PartType::Multipart(v), - }, - encoding: self.encoding, - offset_header: self.offset_header, - offset_body: self.offset_body, - offset_end: self.offset_end, - } - } -} - -impl<'x> fmt::Display for MessagePart<'x> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.write_str(self.text_contents().unwrap_or("[no contents]")) - } -} - -impl<'x> MimeHeaders<'x> for MessagePart<'x> { - fn content_description(&self) -> Option<&str> { - self.headers - .rfc(&RfcHeader::ContentDescription) - .and_then(|header| header.as_text_ref()) - } - - fn content_disposition(&self) -> Option<&ContentType> { - self.headers - .rfc(&RfcHeader::ContentDisposition) - .and_then(|header| header.as_content_type_ref()) - } - - fn content_id(&self) -> Option<&str> { - self.headers - .rfc(&RfcHeader::ContentId) - .and_then(|header| header.as_text_ref()) - } - - fn content_transfer_encoding(&self) -> Option<&str> { - self.headers - .rfc(&RfcHeader::ContentTransferEncoding) - .and_then(|header| header.as_text_ref()) - } - - fn content_type(&self) -> Option<&ContentType> { - self.headers - .rfc(&RfcHeader::ContentType) - .and_then(|header| header.as_content_type_ref()) - } - - fn content_language(&self) -> &HeaderValue { - self.headers - .rfc(&RfcHeader::ContentLanguage) - .unwrap_or(&HeaderValue::Empty) - } - - fn content_location(&self) -> Option<&str> { - self.headers - .rfc(&RfcHeader::ContentLocation) - .and_then(|header| header.as_text_ref()) - } -} - pub trait GetHeader { fn rfc(&self, name: &RfcHeader) -> Option<&HeaderValue>; fn header(&self, name: &str) -> Option<&Header>; } -impl<'x> GetHeader for Vec> { - fn rfc(&self, name: &RfcHeader) -> Option<&HeaderValue<'x>> { - self.iter() - .rev() - .find(|header| matches!(&header.name, HeaderName::Rfc(rfc_name) if rfc_name == name)) - .map(|header| &header.value) - } - - fn header(&self, name: &str) -> Option<&Header> { - self.iter() - .rev() - .find(|header| header.name.as_str().eq_ignore_ascii_case(name)) - } -} - #[doc(hidden)] pub struct BodyPartIterator<'x> { message: &'x Message<'x>, @@ -1671,131 +711,3 @@ pub struct AttachmentIterator<'x> { message: &'x Message<'x>, pos: isize, } - -impl<'x> BodyPartIterator<'x> { - fn new(message: &'x Message<'x>, list: &'x [MessagePartId]) -> BodyPartIterator<'x> { - BodyPartIterator { - message, - list, - pos: -1, - } - } -} - -impl<'x> Iterator for BodyPartIterator<'x> { - type Item = &'x MessagePart<'x>; - - fn next(&mut self) -> Option { - self.pos += 1; - self.message.parts.get(*self.list.get(self.pos as usize)?) - } -} - -impl<'x> AttachmentIterator<'x> { - fn new(message: &'x Message<'x>) -> AttachmentIterator<'x> { - AttachmentIterator { message, pos: -1 } - } -} - -impl<'x> Iterator for AttachmentIterator<'x> { - type Item = &'x MessagePart<'x>; - - fn next(&mut self) -> Option { - self.pos += 1; - self.message.attachment(self.pos as usize) - } -} - -/// An RFC2047 Content-Type or RFC2183 Content-Disposition MIME header field. -impl<'x> ContentType<'x> { - /// Returns the type - pub fn ctype(&self) -> &str { - &self.c_type - } - - /// Returns the sub-type - pub fn subtype(&self) -> Option<&str> { - self.c_subtype.as_ref()?.as_ref().into() - } - - /// Returns an attribute by name - pub fn attribute(&self, name: &str) -> Option<&str> { - self.attributes - .as_ref()? - .iter() - .find(|(key, _)| key == name)? - .1 - .as_ref() - .into() - } - - /// Removes an attribute by name - pub fn remove_attribute(&mut self, name: &str) -> Option> { - let attributes = self.attributes.as_mut()?; - - attributes - .iter() - .position(|(key, _)| key == name) - .map(|pos| attributes.swap_remove(pos).1) - } - - /// Returns all attributes - pub fn attributes(&self) -> Option<&[(Cow, Cow)]> { - self.attributes.as_deref() - } - - /// Returns `true` when the provided attribute name is present - pub fn has_attribute(&self, name: &str) -> bool { - self.attributes - .as_ref() - .map_or_else(|| false, |attr| attr.iter().any(|(key, _)| key == name)) - } - - /// Returns ```true``` if the Content-Disposition type is "attachment" - pub fn is_attachment(&self) -> bool { - self.c_type.eq_ignore_ascii_case("attachment") - } - - /// Returns ```true``` if the Content-Disposition type is "inline" - pub fn is_inline(&self) -> bool { - self.c_type.eq_ignore_ascii_case("inline") - } -} - -impl<'x> PartType<'x> { - #[allow(clippy::len_without_is_empty)] - pub fn len(&self) -> usize { - match self { - PartType::Text(v) | PartType::Html(v) => v.len(), - PartType::Binary(v) | PartType::InlineBinary(v) => v.len(), - PartType::Message(v) => v.raw_message.len(), - PartType::Multipart(_) => 0, - } - } -} - -impl From for i64 { - fn from(value: DateTime) -> Self { - value.to_timestamp() - } -} - -impl From for String { - fn from(header: RfcHeader) -> Self { - header.to_string() - } -} - -impl From for Cow<'_, str> { - fn from(header: RfcHeader) -> Self { - Cow::Borrowed(header.as_str()) - } -} - -impl<'x> TryInto> for &'x [u8] { - type Error = (); - - fn try_into(self) -> Result, Self::Error> { - Message::parse(self).ok_or(()) - } -} diff --git a/src/mailbox/maildir.rs b/src/mailbox/maildir.rs index 682d66f..fec77f2 100644 --- a/src/mailbox/maildir.rs +++ b/src/mailbox/maildir.rs @@ -280,10 +280,6 @@ mod tests { #[test] fn parse_maildir() { - let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - test_dir.push("tests"); - test_dir.push("maildir"); - let mut messages = Vec::new(); let expected_messages = vec![ ( @@ -342,7 +338,14 @@ mod tests { ), ]; - for folder in FolderIterator::new(test_dir, ".".into()).unwrap() { + for folder in FolderIterator::new( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("resources") + .join("maildir"), + ".".into(), + ) + .unwrap() + { let folder = folder.unwrap(); let name = folder.name().unwrap_or("INBOX").to_string(); diff --git a/src/parsers/fields/address.rs b/src/parsers/fields/address.rs index 7735035..4332282 100644 --- a/src/parsers/fields/address.rs +++ b/src/parsers/fields/address.rs @@ -471,10 +471,10 @@ pub fn parse_address_detail_part(addr: &str) -> Option<&str> { } mod tests { + use super::*; #[test] fn parse_addresses() { use super::*; - let inputs = [ ( "John Doe \n", @@ -1000,6 +1000,8 @@ mod tests { ), ]; + let mut builder = crate::parsers::fields::TestBuilder::new("address.json"); + for input in inputs { let str = input.0.to_string(); let result = MessageStream::new(str.as_bytes()).parse_address(); @@ -1032,6 +1034,10 @@ mod tests { }*/ assert_eq!(result, expected, "Failed for '{:?}'", input.0); + + builder.add(str, expected); } + + builder.write(); } } diff --git a/src/parsers/fields/mod.rs b/src/parsers/fields/mod.rs index 5d00310..60e9663 100644 --- a/src/parsers/fields/mod.rs +++ b/src/parsers/fields/mod.rs @@ -18,3 +18,60 @@ pub mod raw; pub mod received; pub mod thread; pub mod unstructured; + +#[cfg(test)] +use serde::{Deserialize, Serialize}; + +#[cfg(test)] +#[derive(Debug, Serialize, Deserialize)] +pub struct Test { + pub header: String, + pub expected: T, +} + +#[cfg(test)] +pub fn load_tests(test_name: &str) -> Vec> { + serde_json::from_slice::>>( + &std::fs::read( + std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("resources") + .join(test_name), + ) + .unwrap(), + ) + .unwrap() +} + +#[cfg(test)] +#[derive(Debug, Default)] +pub struct TestBuilder { + test: std::path::PathBuf, + tests: Vec>, +} + +#[cfg(test)] +impl TestBuilder { + pub fn new(test: impl AsRef) -> Self { + Self { + test: std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("resources") + .join(test.as_ref()), + tests: Vec::new(), + } + } + + pub fn add(&mut self, header: impl Into, expected: T) { + self.tests.push(Test { + header: header.into(), + expected, + }); + } + + pub fn write(&self) { + std::fs::write( + &self.test, + serde_json::to_string_pretty(&self.tests).unwrap(), + ) + .unwrap(); + } +} diff --git a/src/parsers/fields/received.rs b/src/parsers/fields/received.rs index e095064..f3b9d3e 100644 --- a/src/parsers/fields/received.rs +++ b/src/parsers/fields/received.rs @@ -11,88 +11,9 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use crate::{parsers::MessageStream, DateTime, HeaderValue}; - -#[cfg(feature = "serde_support")] -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, PartialEq, Eq, Default)] -#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -pub struct Received<'x> { - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - from: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - from_ip: Option, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - from_iprev: Option<&'x str>, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - by: Option>, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - for_: Option<&'x str>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - with: Option, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - tls_version: Option, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - tls_cipher: Option<&'x str>, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - id: Option<&'x str>, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - ident: Option<&'x str>, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - helo: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - helo_cmd: Option, - #[cfg_attr( - feature = "serde_support", - serde(borrow, skip_serializing_if = "Option::is_none") - )] - via: Option<&'x str>, - date: Option, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -pub enum Host<'x> { - Name(&'x str), - IpAddr(IpAddr), -} +use crate::{ + parsers::MessageStream, DateTime, Greeting, HeaderValue, Host, Protocol, Received, TlsVersion, +}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum Token { @@ -135,60 +56,6 @@ struct TokenData<'x> { bracket_depth: u32, } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -enum TlsVersion { - SSLv2, - SSLv3, - TLSv1_0, - TLSv1_1, - TLSv1_2, - TLSv1_3, - DTLSv1_0, - DTLSv1_2, - DTLSv1_3, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -enum Greeting { - Helo, - Ehlo, - Lhlo, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -#[allow(clippy::upper_case_acronyms)] -enum Protocol { - // IANA Mail Transmission Types - SMTP, - ESMTP, - ESMTPA, - ESMTPS, - ESMTPSA, - LMTP, - LMTPA, - LMTPS, - LMTPSA, - MMS, - UTF8SMTP, - UTF8SMTPA, - UTF8SMTPS, - UTF8SMTPSA, - UTF8LMTP, - UTF8LMTPA, - UTF8LMTPS, - UTF8LMTPSA, - - // Non-Standard Mail Transmission Types - HTTP, - HTTPS, - IMAP, - POP3, - Local, // includes stdin, socket, etc. -} - #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum Month { Jan, @@ -228,8 +95,8 @@ enum State { } impl<'x> MessageStream<'x> { - pub fn parse_received(&mut self) -> Received<'x> { - let c = print!("-> {}", std::str::from_utf8(self.data).unwrap()); + pub fn parse_received(&mut self) -> HeaderValue<'x> { + //let c = print!("-> {}", std::str::from_utf8(self.data).unwrap()); let mut tokenizer = Tokenizer::new(self).peekable(); let mut received = Received::default(); @@ -255,7 +122,7 @@ impl<'x> MessageStream<'x> { _ => { if !token.token.is_separator() { received.from = - Some(Host::Name(tokenizer.next().unwrap().text)); + Some(Host::Name(tokenizer.next().unwrap().text.into())); } break; } @@ -277,7 +144,8 @@ impl<'x> MessageStream<'x> { } _ => { if !token.token.is_separator() { - received.by = Some(Host::Name(tokenizer.next().unwrap().text)); + received.by = + Some(Host::Name(tokenizer.next().unwrap().text.into())); } break; } @@ -292,7 +160,7 @@ impl<'x> MessageStream<'x> { tokenizer.next(); } Token::Email => { - received.for_ = Some(tokenizer.next().unwrap().text); + received.for_ = Some(tokenizer.next().unwrap().text.into()); break; } _ => { @@ -313,7 +181,7 @@ impl<'x> MessageStream<'x> { } _ => { if !token.token.is_separator() { - received.id = Some(tokenizer.next().unwrap().text); + received.id = Some(tokenizer.next().unwrap().text.into()); } break; } @@ -354,7 +222,7 @@ impl<'x> MessageStream<'x> { } _ => { if !token.token.is_separator() { - received.via = Some(tokenizer.next().unwrap().text); + received.via = Some(tokenizer.next().unwrap().text.into()); } break; } @@ -370,7 +238,7 @@ impl<'x> MessageStream<'x> { } _ => { if !token.token.is_separator() { - received.ident = Some(tokenizer.next().unwrap().text); + received.ident = Some(tokenizer.next().unwrap().text.into()); } break; } @@ -393,7 +261,7 @@ impl<'x> MessageStream<'x> { _ => { if !token.token.is_separator() { received.helo = - Some(Host::Name(tokenizer.next().unwrap().text)); + Some(Host::Name(tokenizer.next().unwrap().text.into())); } break; } @@ -410,12 +278,13 @@ impl<'x> MessageStream<'x> { } Token::Domain => { if state == State::From && token.comment_depth > 0 { - received.from_iprev = Some(token.text); + received.from_iprev = Some(token.text.into()); } } Token::Email => { if state == State::From { - received.ident = Some(token.text.strip_suffix('@').unwrap_or(token.text)); + received.ident = + Some(token.text.strip_suffix('@').unwrap_or(token.text).into()); } } Token::Integer(num) => { @@ -432,8 +301,10 @@ impl<'x> MessageStream<'x> { } } } - Token::Cipher if token.comment_depth > 0 => { - received.tls_cipher = Some(token.text); + Token::Cipher => { + if token.comment_depth > 0 || received.tls_cipher.is_none() { + received.tls_cipher = Some(token.text.into()); + } } Token::TlsVersion(tls) if token.comment_depth > 0 && received.tls_version.is_none() => @@ -472,7 +343,25 @@ impl<'x> MessageStream<'x> { .into(); } - received + if received.from.is_some() + || received.from_ip.is_some() + || received.from_iprev.is_some() + || received.by.is_some() + || received.for_.is_some() + || received.with.is_some() + || received.tls_version.is_some() + || received.tls_cipher.is_some() + || received.id.is_some() + || received.ident.is_some() + || received.helo.is_some() + || received.helo_cmd.is_some() + || received.via.is_some() + || received.date.is_some() + { + HeaderValue::Received(Box::new(received)) + } else { + HeaderValue::Empty + } } } @@ -871,10 +760,10 @@ impl<'x, 'y> Iterator for Tokenizer<'x, 'y> { } }; - println!("{:?} => {}", token, text); + /*println!("{:?} => {}", token, text); if let Some(token) = &self.next_token { println!("{:?}", token.token); - } + }*/ TokenData { text, @@ -912,7 +801,7 @@ impl<'x> From for TokenData<'x> { } impl Month { - fn to_number(&self) -> i64 { + fn to_number(self) -> i64 { match self { Month::Jan => 1, Month::Feb => 2, @@ -952,23 +841,23 @@ impl Token { #[cfg(test)] mod tests { - use std::io::BufRead; - use serde::{Deserialize, Serialize}; - - use crate::parsers::MessageStream; - - use super::Received; - - #[derive(Debug, Serialize, Deserialize)] - struct Test<'x> { - header: &'x str, - expected: Received<'x>, - } + use crate::parsers::{fields::load_tests, MessageStream}; #[test] fn parse_received() { - let file = std::fs::File::open("/Users/me/code/mail-parser/test/headers.txt").unwrap(); + for test in load_tests("received.json") { + assert_eq!( + MessageStream::new(test.header.as_bytes()) + .parse_received() + .unwrap_received(), + test.expected, + "failed for {:?}", + test.header + ); + } + + /*let file = std::fs::File::open("/Users/me/code/mail-parser/test/headers.txt").unwrap(); //let file = std::fs::File::open("/Users/me/code/mail-parser/test/tokens.txt").unwrap(); let reader = std::io::BufReader::new(file); let mut lines = String::new(); @@ -981,7 +870,9 @@ mod tests { let mut tests = vec![]; for line in lines.split_inclusive('\n') { - let expected = MessageStream::new(line.as_bytes()).parse_received(); + let expected = MessageStream::new(line.as_bytes()) + .parse_received() + .unwrap_received(); tests.push(Test { header: line, @@ -993,6 +884,6 @@ mod tests { "/Users/me/code/mail-parser/test/headers.json", serde_json::to_string_pretty(&tests).unwrap(), ) - .unwrap(); + .unwrap();*/ } } diff --git a/src/parsers/message.rs b/src/parsers/message.rs index 5b106d8..9a299cb 100644 --- a/src/parsers/message.rs +++ b/src/parsers/message.rs @@ -545,9 +545,10 @@ mod tests { #[test] fn parse_full_messages() { for test_suite in ["rfc", "legacy", "thirdparty", "malformed"] { - let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - test_dir.push("tests"); - test_dir.push(test_suite); + let test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("resources") + .join("eml") + .join(test_suite); let mut tests_run = 0;