From 7d46438c015e400ca6c035f5d99da040e6765740 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 14 Mar 2021 17:23:38 +0100 Subject: Debug email content types Figuring out the different content types and subparts for different kinds of emails. --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 3c218d2..fbb6976 100644 --- a/src/main.rs +++ b/src/main.rs @@ -128,6 +128,8 @@ fn run() -> Result<(), OttolangyError> { fn get_email_body(email: &[u8]) -> Result { let email = mailparse::parse_mail(&email)?; + println!("ctype: {:?}", email.ctype); + if email.subparts.is_empty() { let body = email.get_body()?; @@ -138,11 +140,18 @@ fn get_email_body(email: &[u8]) -> Result { // TODO: New predicate function for text/plain // TODO: Maybe split into functions for part in email.subparts { + // if part.headers.get_app_values() is one of: + // "multipart/alternative" + // "text/plain" + + println!("part ctype: {:?}", part.ctype); + for header in part.get_headers() { if header.get_key() == "Content-Type" && header.get_value().starts_with("multipart/alternative") { for alternative_part in &part.subparts { + println!("apart ctype: {:?}", alternative_part.ctype); for alternative_header in alternative_part.get_headers() { if alternative_header.get_key() == "Content-Type" && alternative_header.get_value().starts_with("text/plain") -- cgit v1.2.3