No Email Notification possible

CMK version: 2.2.0p21-RAW
OS version: Ubuntu 22.04

**Error message: “No such file or directory: ‘/usr/sbin/sendmail’” **

I did test sending mail as described in documentation, section 3.2 Notifications - via Email, SMS, ticket system and more

I did NOT install an local MTA because the heirloom-mailx already is able to speak to an external SMTP-Server. Therefore I edited the configuration in ~/etc/mail.rc from site-user with additional parameters:

set smtp=smtp://mx.example.com
set from="checkmk@example.com"

Testing:

OMD[mysite]:~$ echo "content" | mail -s test-subject harry.hirsch@example.com

This does send an email as expected, but checkmk always complains about missing sendmail.

this seems to be ignored or do i need to configure additional parameter in CMK?

bump - any one with a hint here?

It is very easy. CMK expects the command “/usr/sbin/sendmail” to exists for the default mail notification plugin.
You can also place your own symlink to another command inside the site as “~/local/bin/sendmail”. But it needs to be “sendmail” as command.

1 Like

If it should be that simple than i wonder why it is stated differently in documentation:

You can test the sending of emails easily with the mail command on the command line. Because there are numerous different implementations for this command under Linux, for standardization Checkmk provides the version from the Heirloom mailx project directly in the site user’s search path (as ~/bin/mail ). The corresponding configuration file is ~/etc/mail.rc . The best way to test this is as a site user, since the notification scripts will later run with the same permissions.

And exactly whith that command i can send email without any need for additional installed software. So it could be much easier than depending on “sendmail” - checkmk delivers all necessary binaries! So my question is, why does checkmk does not use this tool when correctly configured?

This is only to test if your system can send mail.
If you read the mentioned manual article correctly you will see that this is only to verify that your system MTA is working as expected.
From the start of the article.

For the successful sending of emails, your Checkmk server must 
have a functioning SMTP-server configuration. Depending on your 
Linux distribution, this could utilize, for example, Postfix, Qmail, 
Exim, or Nullmailer. The configuration will be implemented with 
your Linux distribution’s resources.
1 Like

So you say, that Checkmk provides this extra mailprogram just to make sure you can test your locally installed sendmail program. That seems very odd to me.

So i would need a complete setup of Postfix or other additional software (MTA) on every instance, make sure that everything is really secure and can not be used for bad things just to provide a solution to send mail from MUA, if OMD already delivers all necessary parts in its distribution and only would need to use this toolset?

How is this problem solved in containerized environments where i do not have the possibility to install such tools?

I’m not sure but I have the impression that ASCII mail notifications require /usr/sbin/sendmail while HTML mail notifications do not because that notification plugin uses the Python smtplib.

Have you tried HTML mails instead of ASCII?

You don’t need a complete MTA setup. The docker container of CMK is using nullmailer that is also providing the /usr/sbin/sendmail binary.
That’s all what you need.

Only if you select “Enable synchronous delivery via SMTP” inside the notification rule.
Code from the mail notification plugin.

def send_mail(message: Message, target: str, from_address: str, context: dict[str, str]) -> int:
    if "PARAMETER_SMTP_PORT" in context:
        return send_mail_smtp(message, MailString(target), MailString(from_address), context)
    send_mail_sendmail(message, MailString(target), MailString(from_address))
    sys.stdout.write("Spooled mail to local mail transmission agent\n")
    return 0
2 Likes

spooky: Four different methods just to deliver an email, where one solution is just for testing purposes and is never used by checkmk itself.

Why is this not streamlined to one simple fully configurable and OS-independent solution?
e.g. the already delivered heirloom-mailx or python smtplib?

What solution can i choose to have a different smtp setup in checkmk than my local OS?
Local mails have to be send differently than mails from checkmk. Different FROM-Adress, different smtp-server, different authentication mechanisms.

Not spooky. We offer you the freedom to choose the MTA you prefer. Why would we re-invent the wheel and build or bundle an MTA in Checkmk, forcing you to use that one?

The one point that is valid here, is that for HTML mail we offer the above-mentioned “synchronous delivery”, which uses smtplib. That is currently the only place in Checkmk, that uses Python to send a mail. I cannot speak to why that is the case and if it will change at some point.

Checkmk by default sends mails from the address $SITE@$HOSTNAME, unless specified differently within Checkmk. So you can configure your MTA to e.g. rewrite the default mails sender, or just specify the appropriate sender address in Checkmk.

1 Like