Error: <strong>Could not execute: /usr/sbin/sendmail</strong><br />

Since a while back I cant produce alerts via email from Librenms. Tbh I’m not really sure how to debug it, so looking for advice. Information is very sparse and I apologize about that, happy to provide whatever.

I see this in the webGUI (for all alerts).

Could not issue recovery for rule ‘Devices up/down’ to transport ‘mail’ Error: <strong>Could not execute: /usr/sbin/sendmail</strong><br />

(or really it’s “Could not issue recovery for rule ‘Devices up/down’ to transport ‘mail’ Error: ‘<‘strong’>‘Could not execute: /usr/sbin/sendmail’<’/strong’>’’<‘br/’>’” but cant copy code here(?)…)

validate, run as librenms is giving some permission errors, but no errors in webgui

root@librenms:/opt/librenms# sudo -u librenms /opt/librenms/validate.php
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
warning: unable to access ‘/root/.gitconfig’: Permission denied

Component Version
LibreNMS 1.50-41-gd069d0fd4
DB Schema 2019_02_10_220000_add_dates_to_fdb (132)
PHP 7.2.15-0ubuntu0.18.04.1
MySQL 10.1.38-MariaDB-0ubuntu0.18.04.1
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3

====================================

[OK] Composer Version: 1.8.5
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
warning: unable to access ‘/root/.config/git/attributes’: Permission denied

Do you have sendmail installed?

Yes, I have sendmail installed.

if I just try to send an email via CLI it works.

root@librenms:~# echo “Subject: sendmail test” | sendmail -v [email protected]
[email protected]… Connecting to [127.0.0.1] via relay…
220 librenms.kroem.eu ESMTP Sendmail 8.15.2/8.15.2/Debian-10; Mon, 20 May 2019 14:01:24 +0200; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]

EHLO librenms.kroem.eu
250-librenms.kroem.eu Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
VERB
250 2.0.0 Verbose mode
MAIL From:[email protected] SIZE=23 [email protected]
250 2.1.0 [email protected]… Sender ok
RCPT To:[email protected]
DATA
250 2.1.5 [email protected]… Recipient ok
354 Enter mail, end with “.” on a line by itself
.
050 [email protected]… Connecting to gmail-smtp-in.l.google.com. via esmtp…
050 220 mx.google.com ESMTP v67si13650781lje.125 - gsmtp
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-STARTTLS
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> MAIL From:[email protected] SIZE=312
050 250 2.1.0 OK v67si13650781lje.125 - gsmtp
050 >>> RCPT To:[email protected]
050 >>> DATA
050 250 2.1.5 OK v67si13650781lje.125 - gsmtp
050 354 Go ahead v67si13650781lje.125 - gsmtp
050 >>> .
050 250 2.0.0 OK 1558353685 v67si13650781lje.125 - gsmtp
050 [email protected]… Sent (OK 1558353685 v67si13650781lje.125 - gsmtp)
250 2.0.0 x4KC1OiI000824 Message accepted for delivery
[email protected]… Sent (x4KC1OiI000824 Message accepted for delivery)
Closing connection to [127.0.0.1]
QUIT
221 2.0.0 librenms.kroem.eu closing connection

warning: unable to access ‘/root/.gitconfig’: Permission denied

I’m not sure how you installed, but at the very least you are going to want to chmod that

Have you tried running /usr/sbin/sendmail as the librenms user?

Sorry, must have pasted the wrong text, yes it works with librenms user:

root@librenms:~# sudo -u librenms echo “Subject: sendmail test” | sendmail -v [email protected]
[email protected]… Connecting to [127.0.0.1] via relay…
220 librenms.kroem.eu ESMTP Sendmail 8.15.2/8.15.2/Debian-10; Mon, 20 May 2019 18:25:03 +0200; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]

EHLO librenms.kroem.eu
250-librenms.kroem.eu Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
VERB
250 2.0.0 Verbose mode
MAIL From:[email protected] SIZE=23 [email protected]
250 2.1.0 [email protected]… Sender ok
RCPT To:[email protected]
DATA
250 2.1.5 [email protected]… Recipient ok
354 Enter mail, end with “.” on a line by itself
.
050 [email protected]… Connecting to gmail-smtp-in.l.google.com. via esmtp…
050 220 mx.google.com ESMTP d4si16886089ljj.8 - gsmtp
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-STARTTLS
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> MAIL From:[email protected] SIZE=312
050 250 2.1.0 OK d4si16886089ljj.8 - gsmtp
050 >>> RCPT To:[email protected]
050 >>> DATA
050 250 2.1.5 OK d4si16886089ljj.8 - gsmtp
050 354 Go ahead d4si16886089ljj.8 - gsmtp
050 >>> .
050 250 2.0.0 OK 1558369504 d4si16886089ljj.8 - gsmtp
050 [email protected]… Sent (OK 1558369504 d4si16886089ljj.8 - gsmtp)
250 2.0.0 x4KGP3AR018353 Message accepted for delivery
[email protected]… Sent (x4KGP3AR018353 Message accepted for delivery)
Closing connection to [127.0.0.1]
QUIT
221 2.0.0 librenms.kroem.eu closing connection

Not sure. Sendmail actually exist there?

Yes, it’s there (I think?). Or am I doing something obviously wrong?

(also, I dont really know how to format stuff properly on this forum, it looks really messy…)

root@librenms:~# which sendmail
/usr/sbin/sendmail
root@librenms:~# /usr/sbin/sendmail
Recipient names must be specified
^Croot@librenms:~# sudo -u librenms echo “Subject: sendmail test” | /usr/sbin/sendmail -v [email protected]
[email protected]… Connecting to [127.0.0.1] via relay…
220 librenms.kroem.eu ESMTP Sendmail 8.15.2/8.15.2/Debian-10; Fri, 24 May 2019 12:15:31 +0200; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]

EHLO librenms.kroem.eu
250-librenms.kroem.eu Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
VERB
250 2.0.0 Verbose mode
MAIL From:[email protected] SIZE=29 [email protected]
250 2.1.0 [email protected]… Sender ok
RCPT To:[email protected]
DATA
250 2.1.5 [email protected]… Recipient ok
354 Enter mail, end with “.” on a line by itself
.
050 [email protected]… Connecting to gmail-smtp-in.l.google.com. via esmtp…
050 220 mx.google.com ESMTP z1si1900181ljk.114 - gsmtp
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-STARTTLS
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> MAIL From:[email protected] SIZE=318
050 250 2.1.0 OK z1si1900181ljk.114 - gsmtp
050 >>> RCPT To:[email protected]
050 >>> DATA
050 250 2.1.5 OK z1si1900181ljk.114 - gsmtp
050 354 Go ahead z1si1900181ljk.114 - gsmtp
050 >>> .
050 250 2.0.0 OK 1558692932 z1si1900181ljk.114 - gsmtp
050 [email protected]… Sent (OK 1558692932 z1si1900181ljk.114 - gsmtp)
250 2.0.0 x4OAFVIr008085 Message accepted for delivery
[email protected]… Sent (x4OAFVIr008085 Message accepted for delivery)
Closing connection to [127.0.0.1]
QUIT
221 2.0.0 librenms.kroem.eu closing connection
root@librenms:~#

I wonder if it is sent via www-data? Kind of doubt it - I’m not sure what else to try, sorry.

Step one is fix your permissions errors. (and running sudo like that doesn’t fully change users because it doesn’t reset the env)

chown -R librenms:librenms /opt/librenms and validate again.

To change to LibreNMS, use:
su - librenms

Yeah sorry didn’t add that, but it’s already done. As librenms user:


$ ./validate.php

Component Version
LibreNMS 1.51-84-gaff2ac49e
DB Schema 2019_02_10_220000_add_dates_to_fdb (132)
PHP 7.2.17-0ubuntu0.18.04.1
MySQL 10.1.38-MariaDB-0ubuntu0.18.04.2
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3
====================================

[OK] Composer Version: 1.8.5
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
$ echo “Subject: sendmail test” | /usr/sbin/sendmail -v [email protected]
[email protected]… Connecting to [127.0.0.1] via relay…
220 librenms.kroem.eu ESMTP Sendmail 8.15.2/8.15.2/Debian-10; Sun, 26 May 2019 09:16:57 +0200; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]

EHLO librenms.kroem.eu
250-librenms.kroem.eu Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
VERB
250 2.0.0 Verbose mode
MAIL From:[email protected] SIZE=29 [email protected]
250 2.1.0 [email protected]… Sender ok
RCPT To:[email protected]
DATA
250 2.1.5 [email protected]… Recipient ok
354 Enter mail, end with “.” on a line by itself
.
050 [email protected]… Connecting to gmail-smtp-in.l.google.com. via esmtp…
050 220 mx.google.com ESMTP b9si6955160ljd.118 - gsmtp
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-STARTTLS
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO librenms.kroem.eu
050 250-mx.google.com at your service, [94.137.110.58]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> MAIL From:[email protected] SIZE=319
050 250 2.1.0 OK b9si6955160ljd.118 - gsmtp
050 >>> RCPT To:[email protected]
050 >>> DATA
050 250 2.1.5 OK b9si6955160ljd.118 - gsmtp
050 354 Go ahead b9si6955160ljd.118 - gsmtp
050 >>> .
050 250 2.0.0 OK 1558855018 b9si6955160ljd.118 - gsmtp
050 [email protected]… Sent (OK 1558855018 b9si6955160ljd.118 - gsmtp)
250 2.0.0 x4Q7GvBq011376 Message accepted for delivery
[email protected]… Sent (x4Q7GvBq011376 Message accepted for delivery)
Closing connection to [127.0.0.1]
QUIT
221 2.0.0 librenms.kroem.eu closing connection
$


LibreNMS actually doesn’t call sendmail. It just calls PHPMailer, when using sendmail instead of other methods, it just passes path to the sendmail executable.

Are you sure you don’t have SELinux enabled?

I dont think so

root@librenms:~# sestatus

Command ‘sestatus’ not found, but can be installed with:

apt install policycoreutils

Any luck with chmod 755 /usr/sbin/sendmail ?

also show output

stat /usr/sbin/sendmail

Hi! No change, I get the same error. :frowning:

root@librenms:~# ls -lvh /usr/sbin/sendmail
lrwxrwxrwx 1 root root 26 Jun 5 2018 /usr/sbin/sendmail -> /etc/alternatives/sendmail
root@librenms:~#
root@librenms:~#
root@librenms:~#
root@librenms:~#
root@librenms:~# chmod 755 /usr/sbin/sendmail
root@librenms:~# ls -lvh /usr/sbin/sendmail
lrwxrwxrwx 1 root root 26 Jun 5 2018 /usr/sbin/sendmail -> /etc/alternatives/sendmail
root@librenms:~# stat /usr/sbin/sendmail
File: /usr/sbin/sendmail -> /etc/alternatives/sendmail
Size: 26 Blocks: 0 IO Block: 4096 symbolic link
Device: fc02h/64514d Inode: 1325649 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-05-27 02:40:01.083585068 +0200
Modify: 2018-06-05 10:01:51.731104399 +0200
Change: 2018-06-05 10:01:51.743103910 +0200
Birth: -
root@librenms:~#

do the same for /etc/alternatives/sendmail aswell, i can’t remember if chmod follows symlinks

Hmm, feels like I’m going down the rabbit hole here, same for /usr/lib/sm.bin/sendmail maybe?

root@librenms:~# chmod 755 /etc/alternatives/sendmail
root@librenms:~# ls -lvh /etc/alternatives/sendmail
lrwxrwxrwx 1 root root 24 Jun 5 2018 /etc/alternatives/sendmail -> /usr/lib/sm.bin/sendmail
root@librenms:~# ls -lvh /usr/lib/sm.bin/sendmail
-rwxr-xr-x 1 root smmsp 845K Jan 13 2018 /usr/lib/sm.bin/sendmail

not sure looks ok to me, i would try to apt purge and reinstall sendmail/postfix

Maybe a setting in your php.ini blocking it?

Tried to purge and install again, no change… :frowning:

How can I check that? :slight_smile: