Postfix / notifications configuration to allow multiple network to send emails

  • Hello,


    TL;DR: It would be nice to have additional OMV variables for Postfix configuration to control those 2 Postfix parameters: mynetworks and mynetworks_style



    I am using containers for some of my tools/apps.
    I was configuring email alert in my Grafana container, pointed at my OMV IP address (which is actually the host of the container) and when testing emails notification, it did not work with the following error in /var/log/mail.log:


    Relay access denied




    After some reading, I found out that the inet_interfaces parameter in /etc/postfix/main.cf was set to my localhost address: 127.0.0.1
    In order for postfix to receive emails from other interfaces, it should be set to all


    I found that there is an OMV environment variable I can change to set it to all: OMV_POSTFIX_MAIN_INET_INTERFACES


    So I added OMV_POSTFIX_MAIN_INET_INTERFACES=all at the end of /etc/default/openmediavault and then I ran omv-salt stage run prepare and reloaded the configuration by just disabling/re-enabling notification from the WebGUI. Checked /etc/postfix/main.cf and noticed it was not properly set to all.


    But it turned out not to be enough, as I was still getting this Relay access denied error when trying to send email from my grafana container.


    Reading further, I found out you also need to set a postfix parameter called mynetworks to the list of networks you want to allow to use the mail relay.
    I tested quickly by adding this parameter in /etc/postfix/main.cf and set it to include my containers network, restarted postfix and validated that it now works !


    However, the issue is: this change will get overwritten by openmediavault next time a change is done to the notification settings ... and openmediavault does not have a variable to set this specific postfix parameter.


    Reading even further some postfix configuration info, I found out about 2 other parameters in postfix: mynetworks_styles and compatibility_level
    mynetworks-styles can either be host or subnet and is a way to dynamically set the value for mynetworks, if set to host, then mynetworks contains only the IPs set on my interfaces. If set to subnet, then mynetworks will contains all the subnets the host is connected to (which is the options that I would like to use: subnet)
    And looking at the default value for mynetworks-styles I found out the following:

    # postconf -d |grep -i mynetworks_style
    mynetworks_style = ${{$compatibility_level} < {2} ? {subnet} : {host}}


    The default value of mynetworks_style is dependent on the value of compatibility_level and by default OVM sets compability_level to 2, so I overrode this setting by adding the OMV_POSTFIX_MAIN_COMPATIBILITY_LEVEL=1at the end of /etc/default/openmediavault.


    After that it all worked !


    However, I do not think it is the best way of doing it as changing compability_level may have other unwanted impacts.


    So I believe it would be nice to have 2 additional OMV variables in order to be able to set/override those 2 postfix parameters: mynetworks and mynetworks_style



    What do you think ? Is there another/better way to do it ?

    • Offizieller Beitrag

    Can someone add a variable for "mynetworks " please?

    You will need to either file an issue or a pull request here - https://github.com/openmediavault/openmediavault/

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • votdev

    Hat das Label gelöst hinzugefügt.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!