Emailrelay package error - not reading from it's config file?

Hello,

I’ve been using emailrelay package with success on OpenWRT 22.
I’ve install and migrate to OpenWRT 25 almost directly - some “cosmetic” adaptations on some configs - but emailrelay isn’t working.

If I use config from the old OpenWRT it does not work. I thing it was from beeing old format.
Tried with OpenWRT 25, changing the values… no goog too.

I check in top command and dispite the changes on config file it always display /usr/bin/emailrelay –no-daemon wich is the base command.

So I end up editing the /etc/init.d/emailrelay file to append the desire flags and…

After a service restart… it works! And in top it shows with all appended flags too.

And I’m able to send emails from OpenWRT router again :slight_smile:

But this was only for testing I wish to make the service read from it’s config file and not changing manually their init.d file!

It seems to me that the init.d file is not picking the configs from /etc/config/emailrelay as it should. I haven’t change nothing more than my print shows in the init.d file so it is exactly as it shows on https://github.com/openwrt/packages/blob/master/mail/emailrelay/files/emailrelay.init.

Any clue?

Thank you, Pedro

Solved!
Changed the init.d script to:

#!/bin/sh /etc/rc.common

START=90

USE_PROCD=1
PROG=/usr/bin/emailrelay
NAME=emailrelay

handle_dnsbl() {
procd_append_param command --dnsbl "$1"
}

handle_filter() {
procd_append_param command --filter "$1"
}

handle_client_filter() {
procd_append_param command --client-filter "$1"
}

handle_interface() {
procd_append_param command --interface "$2=$1"
}

emailrelay_instance()
{
local enabled mode port remote_clients anonymous domain address_verifier spool_dir delivery_dir server_auth server_tls server_tls_required server_tls_key server_tls_certificate server_tls_verify client_auth client_tls client_tls_required client_tls_key client_tls_certificate client_tls_verify smarthost smtp_client_interface pop pop_port pop_auth pop_by_name extra_cmdline

config_get_bool enabled "$1" enabled
[ "$enabled" = 0 ] && return 1
config_get mode "$1" mode
config_get port "$1" port
config_get_bool remote_clients "$1" remote_clients
config_list_foreach "$1" dnsbl handle_dnsbl
config_get_bool server_tls "$1" server_tls
config_get_bool server_tls_required "$1" server_tls_required
config_get server_tls_key "$1" server_tls_key
config_get server_tls_certificate "$1" server_tls_certificate
config_get server_tls_verify "$1" server_tls_verify
config_get server_auth "$1" server_auth
config_list_foreach "$1" filter handle_filter
config_get extra_cmdline "$1" extra_cmdline
config_list_foreach "$1" smtp_server_interface handle_interface "smtp"
config_get smarthost "$1" smarthost
config_get smtp_client_interface "$1" smtp_client_interface
config_get_bool client_tls "$1" client_tls
config_get_bool client_tls_required "$1" client_tls_required
config_get client_tls_key "$1" client_tls_key
config_get client_tls_certificate "$1" client_tls_certificate
config_get client_tls_verify "$1" client_tls_verify
config_get client_auth "$1" client_auth
config_get address_verifier "$1" address_verifier
config_get domain "$1" domain
config_get_bool anonymous "$1" anonymous
config_list_foreach "$1" client_filter handle_client_filter
config_get spool_dir "$1" spool_dir
config_get delivery_dir "$1" delivery_dir
config_get_bool pop "$1" pop
config_get pop_port "$1" pop_port
config_get pop_auth "$1" pop_auth
config_get_bool pop_by_name "$1" pop_by_name
config_list_foreach "$1" pop_server_interface handle_interface "pop"

procd_open_instance
procd_set_param command "$PROG" --no-daemon

case "$mode" in
"client"|\
"server"|\
"proxy")
if [ "$mode" = "proxy" ];
then
if [ -n "$smarthost" ]
then
if [ -n "$port" ];
then procd_append_param command "--as-${mode}=$smarthost:$port"
else
procd_append_param command "--as-${mode}=$smarthost"
fi
else
[ -n "$port" ] && procd_append_param command --port "$port"
fi
else
procd_append_param command "--as-${mode}"
fi
[ "$remote_clients" = 1 ] && procd_append_param command --remote-clients
[ "$server_tls" = 1 ] && procd_append_param command --server-tls
[ "$server_tls_required" = 1 ] && procd_append_param command --server-tls-required
[ -n "$server_tls_key" ] && procd_append_param command --server-tls-certificate "$server_tls_key"
[ -n "$server_tls_certificate" ] && procd_append_param command --server-tls-certificate "$server_tls_certificate"
[ -n "$server_tls_verify" ] && procd_append_param command --server-tls-verify "$server_tls_verify"
[ -n "$server_auth" ] && procd_append_param command "--server-auth=$server_auth"
[ "$client_tls" = 1 ] && procd_append_param command --client-tls
[ "$client_tls_required" = 1 ] && procd_append_param command --client-tls-required
[ -n "$client_tls_key" ] && procd_append_param command --client-tls-certificate "$client_tls_key"
[ -n "$client_tls_certificate" ] && procd_append_param command --client-tls-certificate "$client_tls_certificate"
[ -n "$client_tls_verify" ] && procd_append_param command --client-tls-verify "$client_tls_verify"
[ -n "$client_auth" ] && procd_append_param command "--client-auth=$client_auth"
[ -n "$smtp_client_interface" ] && procd_append_param command --client-interface "$smtp_client_interface"
[ -n "$address_verifier" ] && procd_append_param command "--address-verifier=$address_verifier"
[ -n "$domain" ] && procd_append_param command "--domain=$domain"
[ "$anonymous" = 1 ] && procd_append_param command --anonymous
[ "$pop" = 1 ] && procd_append_param command --pop
[ -n "$pop_port" ] && procd_append_param command --pop-port "$pop_port"
[ -n "$pop_auth" ] && procd_append_param command "--pop-auth=$pop_auth"
[ "$pop_by_name" = 1 ] && procd_append_param command --pop-by-name
[ -n "$spool_dir" ] && procd_append_param command --spool-dir "$spool_dir"
[ -n "$delivery_dir" ] && procd_append_param command --delivery-dir "$delivery_dir"
;;
"cmdline")
# empty by intention (just append extra_cmdline)
;;
*)
echo "no mode specified"
return 1
;;
esac

[ -n "$extra_cmdline" ] && procd_append_param command $extra_cmdline
# procd_append_param command --forward-to-some

[ ! -d "${spool_dir:-/var/spool/emailrelay}" ] && mkdir -p "${spool_dir:-/var/spool/emailrelay}"
[ ! -d "${delivery_dir:-/var/spool/emailrelay/in}" ] && mkdir -p "${delivery_dir:-/var/spool/emailrelay/in}"

procd_set_param respawn

procd_close_instance
}

start_service()
{
config_load "${NAME}"
config_foreach emailrelay_instance emailrelay
}

Have only tested in proxy mode which is the only method I’m using and can test and that previously wasn’t started at all with the default /etc/init.d/emailrelay file.

Followed the https://emailrelay.sourceforge.net/reference.html for the args formatting style.

Greetings, Pedro

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.