SOLVED Upgrade 11.2-11.3 broke plain text emails-How do I keep formatting on email reports?

NASbox

Guru
Joined
May 8, 2012
Messages
650
I am trying to send a plain text report (which depends on blank spaces for readability.

I had something working for a month or so, then I upgraded from FreeNAS 11.2-U7 to FreeNAS 11.3-U4.1 and my report will no longer display properly in thunderbird. The problem seems to be that sendmail has been changed an has decedied to turn my mail into an attachments. Is this a bug?

Most important is how can I work around ths quickly.

I have a script that creates a text file which is sent using:
sendmail -t </tmp/zpool_report.tmp

Contents of /tmp/zpool_report.tmp is:
Code:
From: user@email.com
To: user@email.com
Subject: ZPool Status Report
Content-Type: text/html
MIME-Version: 1.0

<pre>
------------ Plain text report created by bash script here
</pre>


Under FreeNAS 11.2-U7, a monospace table displayed spaces correctly in Thunderbird because the mailer sent a text file without turning it into an attachment.

Code:
----------------------HEADER INFO REMOVED
Date: Mon, 14 Sep 2020 12:00:01 -0000
Message-ID: <xxxxxxx-20200914.120001.470804.b'Z1G-'@XXXXXXXXXX>
X-Mailer: FreeNAS
X-FreeNAS-Host: XXXXXXXXXX

CjxwcmUgc3R5bGU9ImZvbnQtc2l6ZToxNHB4Ij4KCiMjIyMjIyMjIyMgWlBvb2wgc3RhdHVzIHJl
cG9ydCBzdW1tYXJ5IGZvciBhbGwgcG9vbHMgb24gTW9uIFNlcCAxNCwgMjAyMCBAIDA4OjAwOjAw
IEVEVAoKCistLS0tLS0tLS0tLS0tLSstLS0tLS0tLSstLS0tLS0rLS0tLS0tKy0tLS0tLSstLS0t
------ Removed for clarity


After the "upgrade" the same email is sent as
Code:
----------------------HEADER INFO REMOVED
Message-ID: <xxxxxxx-20200915.120001.960836.b'ZPLo'@XXXXXXXXXX>
X-Mailer: FreeNAS
X-FreeNAS-Host: XXXXXXXXXX

This is a multi-part message in MIME format.
--===============1312279202446736124==
Content-Type: multipart/alternative; boundary="===============4245250433065411735=="
MIME-Version: 1.0

--===============4245250433065411735==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

CjxwcmUgc3R5bGU9ImZvbnQtc2l6ZToxNHB4Ij4KCiMjIyMjIyMjIyMgWlBvb2wgc3RhdHVzIHJl
cG9ydCBzdW1tYXJ5IGZvciBhbGwgcG9vbHMgb24gVHVlIFNlcCAxNSwgMjAyMCBAIDA4OjAwOjAw
IEVEVAoKCistLS0tLS0tLS0tLS0tLSstLS0tLS0tLSstLS0tLS0rLS0tLS0tKy0tLS0tLSstLS0t
------ Removed for clarity
VyBBQ1BJIFRoZXJtYWwgVFowIFRlbXBlcmF0dXJlOiAyNy45QwpIVyBBQ1BJIFRoZXJtYWwgVFox
IFRlbXBlcmF0dXJlOiAyOS45QwoKCjwvcHJlPgo=

--===============4245250433065411735==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
L0VOIj4KCjxicj4KJmx0O3ByZSBzdHlsZT0mcXVvdDtmb250LXNpemU6MTRweCZxdW90OyZndDs8
------ Removed for clarity
GJyPgombHQ7L3ByZSZndDs8YnI+Cgo=

--===============4245250433065411735==--

--===============1312279202446736124==--
 
Last edited:
Joined
Jul 10, 2016
Messages
521
This is correct; 11.3 is more fussy and expects that you add proper MIME boundaries when embedding HTML tags.
There are a few threads out there on this subject that provide examples/solutions, e.g.:

 

NASbox

Guru
Joined
May 8, 2012
Messages
650
Thanks Jurgen Segaert your reference was very helpful. I used the link you posted to derive the answer below.

I've posted my revised code here so the next person in need won't have to waste time figuring it out-hope someone finds this useful.
This works under FreeNAS 11.3-U4.1 and displays properly with Thunderbird and allows sending a plain text report.


Code:
#!/bin/sh

### Parameters ###
logfile="/tmp/report-file.tmp"
fromemail="sender@email.com"
toemail="receiver@email.com"
subject="REPORT TITLE HERE"
boundary="gc0p4Jq0M2Yt08jU534c0p"

### Set email headers ###
(
    echo "From: ${email}"
    echo "To: ${email}"
    echo "Subject: ${subject}"
    echo 'Content-Type: multipart/alternative; boundary="'$boundary'"'
    echo "Content-Type: text"
    echo "MIME-Version: 1.0"
    echo
    echo "--$boundary"
    echo 'Content-Type: text/plain; charset="utf-8"'
    echo "Content-Transfer-Encoding: quoted-printable"
    echo "Content-Disposition: inline"
) > "$logfile"
(
# Code to Generate report goes here
# Code to Generate report goes here
# Code to Generate report goes here
echo "--$boundary"   # This must be the last line of the text report
) >> "$logfile"

### Send report ###
sendmail -t < $logfile
rm "$logfile"


The file "$logfile" that is sent looks like this:

Code:
From: sender@email.com
To: receiver@email.com
Subject: REPORT TITLE HERE
Content-Type: multipart/alternative; boundary="gc0p4Jq0M2Yt08jU534c0p"
Content-Type: text
MIME-Version: 1.0

--gc0p4Jq0M2Yt08jU534c0p
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
------------ PLAIN TEXT REPORT HERE
------------ PLAIN TEXT REPORT HERE
------------ PLAIN TEXT REPORT HERE
------------ PLAIN TEXT REPORT HERE
--gc0p4Jq0M2Yt08jU534c0p
 
Last edited:

NASbox

Guru
Joined
May 8, 2012
Messages
650
This is correct; 11.3 is more fussy and expects that you add proper MIME boundaries when embedding HTML tags.

I'm wondering why this change was made? Did the email spec change to necessitate all this other crap? I can understand the necessity if the content is html, or if it is mixed text/html, but why make things more complicated than necessary?
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I'm wondering why this change was made? Did the email spec change to necessitate all this other crap?
I figure it is either that the underlying version of FreeBSD changed which incorporated a newer version of sendmail that has some new / additional features, OR it could be that they did it just to ruin all the scripts that were running just fine for the last decade or so.
I figure it was intended to be an enhancement.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478

NASbox

Guru
Joined
May 8, 2012
Messages
650
I figure it is either that the underlying version of FreeBSD changed which incorporated a newer version of sendmail that has some new / additional features, OR it could be that they did it just to ruin all the scripts that were running just fine for the last decade or so.
I figure it was intended to be an enhancement.

I was hoping my question would reach someone who is very familiar with the development/knows the developers. The FreeNAS developers will know if they made a change. Likewise IIUC there are some people with ties to the BSD Development community would would either know or know someone who knows.

I fixed these 11.3-related MIME-encoding issues with zpool_report.sh back in February 2020:

Thanks, your solution works fine in your scripts.

I wanted a solution that didn't require turning a plain text email into an html email.

I need only plain text, and I preferred to not clutter it up with a bunch of crap like <html><head></head><body><pre style=\"font-size:14px; white-space:pre\">". Not a big deal either way
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
I was hoping my question would reach someone who is very familiar with the development/knows the developers. The FreeNAS developers will know if they made a change. Likewise IIUC there are some people with ties to the BSD Development community would would either know or know someone who knows.



Thanks, your solution works fine in your scripts.

I wanted a solution that didn't require turning a plain text email into an html email.

I need only plain text, and I preferred to not clutter it up with a bunch of crap like <html><head></head><body><pre style=\"font-size:14px; white-space:pre\">". Not a big deal either way
"I feel your pain." -- I just want a fixed-width font in these messages, too. But we have to work with the tools at hand... :smile:
 

das1996

Dabbler
Joined
May 26, 2020
Messages
25
Sorry to bring up an old thread, but this seems relevant to the question.

Truenas core 13.0u51

When sending emails, the From: header appears as

From: =?utf-8?q?somenamedefinedinemailsettings?=

Any idea why the from field is being send as quoted-printed characters?
 
Top