aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2021-03-14 17:23:38 +0100
committerTeddy Wing2021-03-14 17:23:38 +0100
commit7d46438c015e400ca6c035f5d99da040e6765740 (patch)
tree71abac75b349f15e726891ea01fbe093f21201cb /src
parent1da0b3e1c34aaaa53f52e8f2960a056109abc4fb (diff)
downloadmutt-ottolangy-7d46438c015e400ca6c035f5d99da040e6765740.tar.bz2
Debug email content types
Figuring out the different content types and subparts for different kinds of emails.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs9
1 files changed, 9 insertions, 0 deletions
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<String, WrapError> {
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<String, WrapError> {
// 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")