mirror of
https://git.proxmox.com/git/proxmox
synced 2025-04-30 12:15:49 +00:00
notify: smtp: add Auto-Submitted
header to email body
`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>
This commit is contained in:
parent
b03c394039
commit
efa607f1b5
@ -1,5 +1,6 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use lettre::message::header::{HeaderName, HeaderValue};
|
||||||
use lettre::message::{Mailbox, MultiPart, SinglePart};
|
use lettre::message::{Mailbox, MultiPart, SinglePart};
|
||||||
use lettre::transport::smtp::client::{Tls, TlsParameters};
|
use lettre::transport::smtp::client::{Tls, TlsParameters};
|
||||||
use lettre::{message::header::ContentType, Message, SmtpTransport, Transport};
|
use lettre::{message::header::ContentType, Message, SmtpTransport, Transport};
|
||||||
@ -199,7 +200,7 @@ impl Endpoint for SmtpEndpoint {
|
|||||||
email_builder = email_builder.to(parse_address(&recipient)?);
|
email_builder = email_builder.to(parse_address(&recipient)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
let email = match ¬ification.content {
|
let mut email = match ¬ification.content {
|
||||||
Content::Template {
|
Content::Template {
|
||||||
title_template,
|
title_template,
|
||||||
body_template,
|
body_template,
|
||||||
@ -232,7 +233,7 @@ impl Endpoint for SmtpEndpoint {
|
|||||||
}
|
}
|
||||||
#[cfg(feature = "mail-forwarder")]
|
#[cfg(feature = "mail-forwarder")]
|
||||||
Content::ForwardedMail { ref raw, title, .. } => {
|
Content::ForwardedMail { ref raw, title, .. } => {
|
||||||
use lettre::message::header::{ContentTransferEncoding, HeaderName, HeaderValue};
|
use lettre::message::header::ContentTransferEncoding;
|
||||||
use lettre::message::Body;
|
use lettre::message::Body;
|
||||||
|
|
||||||
let parsed_message = mail_parser::Message::parse(raw)
|
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
|
transport
|
||||||
.send(&email)
|
.send(&email)
|
||||||
.map_err(|err| Error::NotifyFailed(self.name().into(), err.into()))?;
|
.map_err(|err| Error::NotifyFailed(self.name().into(), err.into()))?;
|
||||||
|
Loading…
Reference in New Issue
Block a user