Update to 11.3-RC2 breaks SMART Reporting Script

Alecmascot

Guru
Joined
Mar 18, 2014
Messages
1,175
After installing 11.3-RC2 the script reporting the SMART disk status was no longer being sent.
The error being reported :

Error: [EFAULT] Failed to send email: string payload expected: <class 'list'>

The sendmail header is being built like this :

Code:
### Set email headers ###
(
    echo "To: ${email}"
    echo "Subject: ${subject}"
    echo "Content-Type: text/html"
    echo "MIME-Version: 1.0"
    echo -e "\r\n"
) > "$logfile"

If I comment out the Content-Type line then the script woks as it used to.
So something about Sendmail changed between 11.2 and 11.3
 

Mr. Slumber

Contributor
Joined
Mar 10, 2019
Messages
182
Thanks for the solution!
 

Kramax

Cadet
Joined
Feb 12, 2020
Messages
4
I believe I found the source of the error and a "proper" fix -- though it is more difficult. I am using the same script and saw this problem. However, just removing the Content-Type did not work for me because then my e-mail client decided it was not actually HTML content. I finally discovered that the python interface the sendmail seems to be using is picky about the actual content and it was presumably expecting both plain text and html content or something like that. I went ahead and crafted a fully "multipart mime" e-mail with both plain text in one part and html text in a second part. The sendmail script then accepted it.

The resulting e-mail text that is given to sendmail looks something like this now:
Code:
To: me@example.com
Subject: Full Detail SMART Status Report for freenas
Content-Type: multipart/alternative; boundary="boundary-string"
Content-Type: text/html
MIME-Version: 1.0


--boundary-string
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Please see the HTML content.

--boundary-string
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<html>
<head>
<style type text/css>
....
</pre></body></html>
--boundary-string--


This is working well for me with my e-mail client. Note that I did not attempt to actually include plain text content -- it is just a forward message to look at the HTML. I am attaching my script I am using which is a slight modification of the script posted by "toolchain" in the thread Set up SMART Reporting via email that I much appreciate! My modified version uses this multi-part mime format and also formats the table a little better to handle things like long serial numbers and such.
 

Attachments

  • smart-report.txt
    5.8 KB · Views: 323

hervon

Patron
Joined
Apr 23, 2012
Messages
353
Works great. Thanks Kramax.
 

ethereal

Guru
Joined
Sep 10, 2012
Messages
762
thank you very much you solved a problem that has been going on for weeks
 

ethereal

Guru
Joined
Sep 10, 2012
Messages
762

NASbox

Guru
Joined
May 8, 2012
Messages
644
@Kramax Thanks for your solution, very helpful. I tweaked it a bit so that it isn't necessary to forcefit an <html> section and have the empty plain text section. If only text is needed, this works under FreeNAS 11.3-U4.1 and displays properly with Thunderbird. I've posted it here so the next person in need won't have to waste time figuring it out.

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

--boundary-string
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
--boundary-string
 
Top