public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox 3/3] notify: update mail-parser dependency to 0.11
Date: Fri, 23 May 2025 14:26:15 +0200	[thread overview]
Message-ID: <20250523122615.251430-7-l.wagner@proxmox.com> (raw)
In-Reply-To: <20250523122615.251430-1-l.wagner@proxmox.com>

Thanks to the regression tests introduced in the previous commit we can
be certain that everything works as it should.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 Cargo.toml                           |  2 +-
 proxmox-notify/src/endpoints/smtp.rs | 12 ++++++------
 proxmox-notify/src/lib.rs            |  3 ++-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 71763c5a..9b91dde0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -90,7 +90,7 @@ ldap3 = { version = "0.11", default-features = false }
 lettre = "0.11.1"
 libc = "0.2.107"
 log = "0.4.17"
-mail-parser = "0.8.2"
+mail-parser = "0.11"
 native-tls = "0.2"
 nix = "0.26.1"
 openssl = "0.10"
diff --git a/proxmox-notify/src/endpoints/smtp.rs b/proxmox-notify/src/endpoints/smtp.rs
index 7ad85de8..b684d8ca 100644
--- a/proxmox-notify/src/endpoints/smtp.rs
+++ b/proxmox-notify/src/endpoints/smtp.rs
@@ -293,17 +293,16 @@ fn build_forwarded_message(
     use lettre::message::Body;
     use tracing::error;
 
-    let parsed_message = mail_parser::Message::parse(raw)
+    let parsed_message = mail_parser::MessageParser::default()
+        .parse(raw)
         .ok_or_else(|| Error::Generic("could not parse forwarded email".to_string()))?;
 
     let root_part = parsed_message
         .part(0)
         .ok_or_else(|| Error::Generic("root message part not present".to_string()))?;
 
-    let raw_body = parsed_message
-        .raw_message()
-        .get(root_part.offset_body..root_part.offset_end)
-        .ok_or_else(|| Error::Generic("could not get raw body content".to_string()))?;
+    let raw_body = &parsed_message.raw_message()
+        [root_part.offset_body as usize..root_part.offset_end as usize];
 
     // We assume that the original message content is already properly
     // encoded, thus we add the original message body in 'Binary' encoding.
@@ -345,7 +344,8 @@ fn build_forwarded_message(
                         use std::fmt::Write;
 
                         for attribute in attributes {
-                            let _ = write!(&mut value, "; {}=\"{}\"", attribute.0, attribute.1);
+                            let _ =
+                                write!(&mut value, "; {}=\"{}\"", attribute.name, attribute.value);
                         }
                     }
                     Some(value)
diff --git a/proxmox-notify/src/lib.rs b/proxmox-notify/src/lib.rs
index 12e59474..38d21618 100644
--- a/proxmox-notify/src/lib.rs
+++ b/proxmox-notify/src/lib.rs
@@ -232,7 +232,8 @@ impl Notification {
     }
     #[cfg(feature = "mail-forwarder")]
     pub fn new_forwarded_mail(raw_mail: &[u8], uid: Option<u32>) -> Result<Self, Error> {
-        let message = mail_parser::Message::parse(raw_mail)
+        let message = mail_parser::MessageParser::default()
+            .parse(raw_mail)
             .ok_or_else(|| Error::Generic("could not parse forwarded email".to_string()))?;
 
         let title = message.subject().unwrap_or_default().into();
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-05-23 12:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23 12:26 [pve-devel] [PATCH debcargo-config/proxmox 0/6] package `mail-parser` for trixie; update proxmox-notify for newest mail-parser version Lukas Wagner
2025-05-23 12:26 ` [pve-devel] [PATCH debcargo-config 1/3] import mail-parser from bookworm Lukas Wagner
2025-05-23 12:26 ` [pve-devel] [PATCH debcargo-config 2/3] package hashify 0.2.6 Lukas Wagner
2025-05-23 12:26 ` [pve-devel] [PATCH debcargo-config 3/3] update mail-parser to 0.11.0 Lukas Wagner
2025-05-23 12:26 ` [pve-devel] [PATCH proxmox 1/3] notify: smtp: move building of forwarded mails to separate function Lukas Wagner
2025-05-23 12:26 ` [pve-devel] [PATCH proxmox 2/3] notify: smtp: add test for building forwarded messages Lukas Wagner
2025-05-23 12:26 ` Lukas Wagner [this message]
2025-05-26 14:01 ` [pve-devel] applied: [PATCH debcargo-config/proxmox 0/6] package `mail-parser` for trixie; update proxmox-notify for newest mail-parser version Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250523122615.251430-7-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal