Mail formatting when sending from script

Cellobita

Contributor
Joined
Jul 15, 2011
Messages
107
I have a bash script - adapted from one I found on a thread on this forum - that sends a SMART report each day at noon. After upgrading from 11.2-U7, I've noticed that the new version of /usr/bin/mail seems to default to an html content, which breaks the formatting of the message. I've attached the before and after versions,

Before (FreeNAS 11.2):

Before (11.2).png


After (FreeNAS 11.3):

After (11.3).png


to make the issue easier to understand.

My question is, how do I force mail to switch back to a plain text content?

TIA
Marcello Marques
Guarujá - SP - Brazil
 

yeliaB

Dabbler
Joined
Jan 10, 2017
Messages
17
I"m in the same boat -- my SMART report is much simpler (basically just output from diff) and the result is essentially unusable.
 

Alecmascot

Guru
Joined
Mar 18, 2014
Messages
1,177
 

Cellobita

Contributor
Joined
Jul 15, 2011
Messages
107
My script is different than the one on the thread mentioned above: basically a bunch of command outputs and echo's redirected to a temporary file, which is then sent to mail with the following line:

Code:
cat $reportfile | /usr/bin/mail -s "* ZFS Status [xxx]" myemail@isp.com
 

yeliaB

Dabbler
Joined
Jan 10, 2017
Messages
17
In my script I have a mail header consisting solely of a To: and a Subject: followed by a blank line, all fed into sendmail -t, which has worked for years. I have no MIME content type to remove. Heck, I even tried adding a MIME-Version line, and a Content-Type of "text/plain" (and even "text/html") and I got no mail sent at all. I've seen elsewhere to replace sendmail with mail -s <subj> followed by the body and recipient, so I tried that, but still just get the HTML version of the message instead of the plain-text version.

I'm pretty much at a loss here as to how to proceed, short of bodging an html wrapper around my diff output...
 

Cellobita

Contributor
Joined
Jul 15, 2011
Messages
107
It seems clear that something changed internally on the mail command from 11.2 to 11.3 - I'll delay upgrading my other systems until we get this sorted out.
 

yeliaB

Dabbler
Joined
Jan 10, 2017
Messages
17
I ended up wrapping <pre></pre> around my report and it's readable again.

It offends my sensibilities, but at least it works...
 

Cellobita

Contributor
Joined
Jul 15, 2011
Messages
107
Works here, too. I appreciate your solution, and will use it - albeit reluctantly - for my systems, but feel that the underlying issue should be better understood, and perhaps fixed.

Regards

Marcello Marques
Guarujá - SP - Brazil
 

Cellobita

Contributor
Joined
Jul 15, 2011
Messages
107
Something changed between 11.3 and 11.3-U1, and the <pre></pre> hack suggested by yeliaB doesn't work anymore...

Any suggestions?
 
Top