Turris Omnia’s notification emails are rejected

I have been using a Turris Omnia router for almost 3 years now. The Omnia works great and it has just been updated to Turris OS 5 which is based on a much more recent version of OpenWRT (19.07).

I fixed an issue a long time ago but the new OS version removed my fix, so here is a quick blog post to remember how to do it again next time so I don’t have to find out again.

Here is the issue: my email server (postfix) rejects emails from senders not giving a fully-qualified hostname when issuing the HELO command and Turris OS provides localhost when sending notification emails, resulting in errors like this:

NOQUEUE: reject: RCPT from unknown[]: 504 5.5.2 <localhost>: Helo command rejected: need fully-qualified hostname; from=<foo@example.com> to=<bar@example.com> proto=ESMTP helo=<localhost>

The notification system uses msmtp to send emails but it uses a configuration generated on the fly by the /usr/bin/notifier script. An easy solution is to hardcode msmtp’s domain option directly in that script in function get_user_server_settings, starting on line 108:

get_user_server_settings() {
        local username=`uci -q get user_notify.smtp.username`
        local password=`uci -q get user_notify.smtp.password`
        local server=`uci -q get user_notify.smtp.server`
        local port=`uci -q get user_notify.smtp.port`
        local security=`uci -q get user_notify.smtp.security`

        echo "domain example.com"
        echo "from $mail_from"
        echo "host $server"
        echo "port $port"

        if [ "$security" = "ssl" ]; then
                echo "tls on"
                echo "tls_starttls off"
                echo "tls_certcheck on"
                echo "tls_trust_file /etc/ssl/certs/ca-certificates.crt"
        elif [ "$security" = "starttls" ]; then
                echo "tls on"
                echo "tls_starttls on"
                echo "tls_certcheck on"
                echo "tls_trust_file /etc/ssl/certs/ca-certificates.crt"
                echo "tls off"

        if [ -n "$username" -a -n "$password" ]; then
                echo "auth on"
                echo "user $username"
                echo "password $password"
                echo "auth off"

That’s all.

Comments Add one by sending me an email.