From: Lukas Wagner <l.wagner@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Shannon Sterz <s.sterz@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox v2 1/4] sendmail: add sendmail crate
Date: Mon, 2 Dec 2024 14:30:23 +0100 [thread overview]
Message-ID: <ec19cea7-a20f-4146-88d3-6986d9808d01@proxmox.com> (raw)
In-Reply-To: <20241202125859.191455-1-s.sterz@proxmox.com>
Thanks for the quick v2, Shannon!
Two comment inline
On 2024-12-02 13:58, Shannon Sterz wrote:
> add the `proxmox-sendmail` crate that makes it easier to send mails via
> the `sendmail` utility. features include:
>
> - multipart/alternative support for html+plain text mails
> - multipart/mixed support for mails with attachments
> - automatic nesting of multipart/alternative and multipart/mixed parts
> - masks multiple receivers by default, can be disabled
> - encoding Subject, To, From, and attachment file names correctly
> - adding an `Auto-Submitted` header to avoid triggering automated mails
>
> also includes several tests to ensure that mails are formatted
> correctly.
>
> Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
> ---
>
> changes since v1 (thanks @ Lukas Wagner <l.wagner@proxmox.com>):
> - make it possible to disable receiver redaction
> - re-structure the mal formatting code; mainly split it into
> multiple functions (`format_header`, `format_body`,
> `format_attachment` etc.)
> - fix multiple typos
You are still missing Debian packaging :)
✂ snip ✂
> +
> + fn format_header(
> + &self,
> + now: i64,
> + file_boundary: &str,
> + html_boundary: &str,
> + ) -> Result<String, Error> {
> + let mut header = String::new();
> +
> + let encoded_to = if self.to.len() > 1 && self.mask_participants {
> + // if the receivers are masked, we know that they don't need to be encoded
> + false
> + } else {
> + // check if there is a recipient that needs encoding
> + self.to.iter().any(|r| !r.is_ascii())
> + };
> +
> + if !self.attachments.is_empty() {
> + header.push_str("Content-Type: multipart/mixed;\n");
> + header.push_str(&format!("\tboundary=\"{file_boundary}\"\n"));
Sorry I missed this in v1, but I think this could be a bit nicer as
use std::fmt::Write;
writeln!(&mut header, "\tboundary=\"{file_boundary}\")?;
This is a bit shorter, easier to read and should be a tiny bit faster as well
(not that it makes an actual noticeable difference here).
Of course this also applies to the other places where you append to the header/body.
--
- Lukas
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-12-02 13:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 12:58 Shannon Sterz
2024-12-02 12:58 ` [pbs-devel] [PATCH proxmox v2 2/4] notify: switch sendmail endpoint over to new crate Shannon Sterz
2024-12-02 12:58 ` [pbs-devel] [PATCH proxmox v2 3/4] sendmail: add mail-forwarder feature Shannon Sterz
2024-12-02 12:58 ` [pbs-devel] [PATCH proxmox v2 4/4] notify: use proxmox-sendmail forward implementation Shannon Sterz
2024-12-02 13:30 ` Lukas Wagner [this message]
2024-12-02 14:17 ` [pbs-devel] [PATCH proxmox v2 1/4] sendmail: add sendmail crate Shannon Sterz
2024-12-02 14:18 ` Shannon Sterz
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=ec19cea7-a20f-4146-88d3-6986d9808d01@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=s.sterz@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