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 2/2] notify: smtp: add `Auto-Submitted` header to email body
Date: Wed, 13 Dec 2023 17:42:01 +0100	[thread overview]
Message-ID: <20231213164201.395505-2-l.wagner@proxmox.com> (raw)
In-Reply-To: <20231213164201.395505-1-l.wagner@proxmox.com>

`Auto-Submitted` is defined in the rfc 5436 [1] and describes how
an automatic response (f.e. ooo replies, etc.) should behave on the
emails. When using `Auto-Submitted: auto-generated` (or any value
other than `none`) automatic replies won't be triggered.

[1]: https://www.rfc-editor.org/rfc/rfc3834.html

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 proxmox-notify/src/endpoints/smtp.rs | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/proxmox-notify/src/endpoints/smtp.rs b/proxmox-notify/src/endpoints/smtp.rs
index 4b8ff2d..15724d3 100644
--- a/proxmox-notify/src/endpoints/smtp.rs
+++ b/proxmox-notify/src/endpoints/smtp.rs
@@ -1,5 +1,6 @@
 use std::time::Duration;
 
+use lettre::message::header::{HeaderName, HeaderValue};
 use lettre::message::{Mailbox, MultiPart, SinglePart};
 use lettre::transport::smtp::client::{Tls, TlsParameters};
 use lettre::{message::header::ContentType, Message, SmtpTransport, Transport};
@@ -199,7 +200,7 @@ impl Endpoint for SmtpEndpoint {
             email_builder = email_builder.to(parse_address(&recipient)?);
         }
 
-        let email = match &notification.content {
+        let mut email = match &notification.content {
             Content::Template {
                 title_template,
                 body_template,
@@ -232,7 +233,7 @@ impl Endpoint for SmtpEndpoint {
             }
             #[cfg(feature = "mail-forwarder")]
             Content::ForwardedMail { ref raw, title, .. } => {
-                use lettre::message::header::{ContentTransferEncoding, HeaderName, HeaderValue};
+                use lettre::message::header::ContentTransferEncoding;
                 use lettre::message::Body;
 
                 let parsed_message = mail_parser::Message::parse(raw)
@@ -322,6 +323,15 @@ impl Endpoint for SmtpEndpoint {
             }
         };
 
+        // `Auto-Submitted` is defined in RFC 5436 and describes how
+        // an automatic response (f.e. ooo replies, etc.) should behave on the
+        // emails. When using `Auto-Submitted: auto-generated` (or any value
+        // other than `none`) automatic replies won't be triggered.
+        email.headers_mut().insert_raw(HeaderValue::new(
+            HeaderName::new_from_ascii_str("Auto-Submitted"),
+            "auto-generated;".into(),
+        ));
+
         transport
             .send(&email)
             .map_err(|err| Error::NotifyFailed(self.name().into(), err.into()))?;
-- 
2.39.2





  reply	other threads:[~2023-12-13 16:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13 16:42 [pve-devel] [PATCH proxmox 1/2] notify: smtp: forward original message instead nesting Lukas Wagner
2023-12-13 16:42 ` Lukas Wagner [this message]
2024-01-08 10:43 ` Lukas Wagner
2024-01-09 13:26 ` Wolfgang Bumiller
2024-01-10  8:28   ` Lukas Wagner

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=20231213164201.395505-2-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