Setting up/replicating Docker Mailserver

I’m cured running Docker Mailserver:

The setup is super imperative and I would like to change this.
Does someone maybe have an example where the configs live more in Nix or even replicated the setup fully in Nix?
I know of the Simple Mailserver but as of know they don’t support relays and I don’t want to run my server from my dynamic residential IP.

I’ve seen simple-nixos-mailserver / nixos-mailserver · GitLab which sounds like exactly what you’re looking for.

1 Like

I think that’s the one which doesn’t support the SMTP relay (at least when I checked it out the last time).
I couldn’t find the related issue on Gitlab.

Hey, do you have any news on this? I need a SMTP relay now and I can’t set up the Simple Mailserver with this.

Doesn’t look like it but you can add ine manually as described in this issue:

2 Likes

I added a comment to this issue.

1 Like

I resolved the issue. Seems like swaks cannot use TLS properly in a nix shell. I tested this now with the msmtp configuration from the nixos.wiki and it works.

smtprelay.nix

{ config, pkgs, ... }: {
services.postfix = {
    mapFiles."sasl_passwd" = builtins.toFile "sasl_passwd" "RELAY_IP RELAY_ACCOUNT:RELAY_PASSWORD";
    relayPort = 465;
    extraMasterConf = ''postlog   unix-dgram n  -       n       -       1       postlogd''; 
    extraConfig =
    ''
      maillog_file = /var/log/postfix.log
      smtp_sasl_auth_enable = yes
      smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
      smtp_sasl_security_options = noanonymous
      smtp_sasl_tls_security_options = noanonymous
      smtp_sasl_mechanism_filter = AUTH LOGIN
    '';
  };
}