public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Lukas Wagner" <l.wagner@proxmox.com>,
	"Proxmox Backup Server development discussion"
	<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox v2 1/4] sendmail: add sendmail crate
Date: Mon, 02 Dec 2024 15:17:57 +0100	[thread overview]
Message-ID: <D61A2MKQRAVY.2LU8410GKQLZ7@proxmox.com> (raw)
In-Reply-To: <ec19cea7-a20f-4146-88d3-6986d9808d01@proxmox.com>

On Mon Dec 2, 2024 at 2:30 PM CET, Lukas Wagner wrote:
> 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 ✂

ah yes, sorry fixed that up in a v3 just now

>
> > +
> > +    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.

alright, switch over instances of `push_str(&format!())` over to
`write!` and `writeln!`


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

  reply	other threads:[~2024-12-02 14:17 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 ` [pbs-devel] [PATCH proxmox v2 1/4] sendmail: add sendmail crate Lukas Wagner
2024-12-02 14:17   ` Shannon Sterz [this message]
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=D61A2MKQRAVY.2LU8410GKQLZ7@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=l.wagner@proxmox.com \
    --cc=pbs-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