digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.71k stars 124 forks source link

btrbk-mail: Lines with >>> are parsed as quotes by email clients #376

Open schildbach opened 3 years ago

schildbach commented 3 years ago

I'm using btrbk 0.27.1 wrapped inside the supplied btrbk-mail script, which sends me an email about success or failure. Unfortunately, the output of btrbk contains consecutive lines starting with >>> which is intepreted as email quotes by email cliens (Thunderbird in my case), making the email hard to read.

I would like to propose to use other characters instead. Maybe »»»?

Alternatively maybe a leading space would prevent the formatting? Or maybe there is an email header that can prevent formatting?

digint commented 3 years ago

I agree this is annoying, I struggle with the same problem since I started writing btrbk, and there is no good solution for this. The problem is that some (most?) mail clients outsmart the specs and replace text/plain mails by quotations, emoticons, emphasis, ... So the only "correct" solution is to disable these features in the client.

Known workarounds:

digint commented 3 years ago

Help wanted

Is it possible to use some special header or different content-type which tells "smart" mail clients to display the text as-is?

schildbach commented 3 years ago

I can very much understand your hesitation to outsmart mail clients, but on the other hand they are unlikely to change this behaviour. I hope we can find a solution that is based on headers.

However, independent from the quotation issue: indenting all "action lines" (and only those) by two or more spaces would improve readbility, much like those lines are indented in the Legend, too. It would even be an improvement for normal shell output I guess.

schildbach commented 3 years ago

I got a suggestion to maybe use content-type: text/html and then put the payload into a <pre> tag.

digint commented 3 years ago

Implemented workaround which allows to prefix btrbk command output:

You can even prefix the lines with zero-width whitespace (note that for me, thunderbird-78.8.0 starts changing the line height for some reasons). Prefixing with . looks good for me, single whitespace also works.

mail_cmd_block_prefix='\\u200B' # zero-width whitespace
mail_cmd_block_prefix=". "

I got a suggestion to maybe use content-type: text/html and then put the payload into a <pre> tag.

This would work, but sending out html mails from a server is probably not the best idea.

luxagen commented 1 year ago
  • 25c5e7b btrbk-mail: optionally prefix command output lines

That's funny - I solved this problem the same way in my cron job for a while by prefixing | to every line from btrbk. I didn't even know btrbk-mail existed!

Your zero-width-whitespace idea is much better though.