Matty9191 / ssl-cert-check

Send notifications when SSL certificates are about to expire.
GNU General Public License v2.0
735 stars 288 forks source link

mail on FreeBSD doesn't support the -r option #49

Closed mpfusion closed 5 years ago

mpfusion commented 5 years ago

mail on FreeBSD doesn't support the -r option. Therefore sending emails fails on FreeBSD.

11.2-STABLE ssl-cert-check Version 3.31

Matty9191 commented 5 years ago

Can you try version 4.1? I make a couple of changes to the mail logic to hopefully address this.

mpfusion commented 5 years ago

Still doesn't work, the error message (not visible) is mail: illegal option -- r. The reason is that mail is still called with the -r flag:

case "${MAILMODE}" in
    "mail")
        echo "$MSG" | ${MAIL} -r $FROM -s "$SUBJECT" $TO
        ;;
    "mailx")
        echo "$MSG" | ${MAIL} $FROM -s "$SUBJECT" $TO

It defaults to mail here and therefore uses the -r $FROM part, which is not valid on my system. BTW: I don't need the from header, since my system sets it automatically to the correct value. But that might not be the case for everyone.

Matty9191 commented 5 years ago

I think I see the issue. Can you try the latest version? Folks should be able to work around the From: issue via their .mailrc.

mpfusion commented 5 years ago

Thanks for the quick fix. Mail is being sent but the subject is empty. I believe passing the TO to mailx won't work like that. Here's the top of the man page from my system:

NAME
     mail, Mail, mailx – send and receive mail

SYNOPSIS
     mail [-dEiInv] [-s subject] [-c cc-addr] [-b bcc-addr] [-F] to-addr ...
          [-sendmail-option ...]
     mail [-dEHiInNv] [-F] -f [name]
     mail [-dEHiInNv] [-F] [-u user]
     mail [-d] -e [-f name]

So I guess this should work:

"mailx")
   echo "$MSG" | "${MAIL}" -s "$SUBJECT" "$TO"
Matty9191 commented 5 years ago

Good catch. Try version 4.8. Hopefully that works. :)

mpfusion commented 5 years ago

Seems to work now. Thanks for the quick fix.