Nixos simplemailserver and nextcloud

Hi,

i trying to use nixos simple mail server to send mails for nextcloud.
Nextcloud is giving me this error:
A problem occurred while sending the email. Please revise your settings. (Error: Email could not be sent. Check your mail server log)

mailserver config:

{ config, pkgs, lib,... }:
   let release = "nixos-23.05";
   in {
     imports = [
       (builtins.fetchTarball {
         url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/${release}/nixos-mailserver-${release}.tar.gz";
         # This hash needs to be updated
         sha256 = "sha256:1ngil2shzkf61qxiqw11awyl81cr7ks2kv3r3k243zz7v2xakm5c";
       })
     ];
mailserver = {
       enable = true;
       fqdn = "mail.example.com";
       domains = [ "example.com"];
       debug = true;
       loginAccounts = {
           "user@example.com" = {
               # nix-shell -p mkpasswd --run 'mkpasswd -sm bcrypt' > /hashed/password/file/location
               hashedPasswordFile = "/var/lib/mail_secrets/xxx";

               aliases = [
                   "@example.com"
               ];
           };
           "noreply@example.com" = {
           hashedPasswordFile = "/var/lib/mail_secrets/xxx";
                };
       };

    # Enable the ManageSieve protocol
    enableManageSieve = true;


    };
   }

The postfix logs:

Sep 05 18:00:14 nixos-server postfix/smtpd[2883514]: connect from unknown[IP]
Sep 05 18:00:14 nixos-server postfix/smtpd[2883514]: SSL_accept error from unknown[IP]: -1
Sep 05 18:00:14 nixos-server postfix/smtpd[2883514]: warning: TLS library problem: error:0A000418:SSL routines::tlsv1 alert unknown ca:ssl/record/rec_layer_s3.c:1586:SSL alert number 48:
Sep 05 18:00:14 nixos-server postfix/smtpd[2883514]: lost connection after STARTTLS from unknown[IP]
Sep 05 18:00:14 nixos-server postfix/smtpd[2883514]: disconnect from unknown[IP] ehlo=1 starttls=0/1 commands=1/2

The noreply mail account works fine with thunderbird

Does anybody has an idea how to solve this?

1 Like

I’m facing the exact error rn. Did you get it working?

Sadly not … But i also did not invested time in last month for that problem

I think I solved it. My certificates were wrong. If you’re using certbot certificate, you need to generate a new certificate for mail subdomain mail.<your_domain>. Certfile is not cert.pem, but fullchain.pem.

That solved TLS issue, but unfortunately I couldn’t get my SMTP server fully functional because my hosting provider blocks outgoing SMTP becuase of SPAM, but I managed to received mails.