From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id DA56CC01C3 for ; Wed, 10 Jan 2024 10:52:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C2048319AE for ; Wed, 10 Jan 2024 10:52:59 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 10 Jan 2024 10:52:59 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E74F149052 for ; Wed, 10 Jan 2024 10:52:58 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Wed, 10 Jan 2024 10:52:52 +0100 Message-Id: <20240110095252.108983-2-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240110095252.108983-1-l.wagner@proxmox.com> References: <20240110095252.108983-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH proxmox v2 2/2] notify: smtp: add `Auto-Submitted` header to email body X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jan 2024 09:52:59 -0000 `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 --- 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 28f9909..5470257 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 ¬ification.content { + let mut email = match ¬ification.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) @@ -325,6 +326,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