docker-mailserver: bug report: SPF Fail - Not authorized in Outlook sending to DMS

๐Ÿ“ Preliminary Checks

  • I tried searching for an existing issue and followed the debugging docs advice, but still need assistance.

๐Ÿ‘€ What Happened?

Although everything works fine on GMail, Proton and Thunderbird (to use to send from my custom email)

I could only send to outlook.com but could not receive, it would return Recipient address rejected: Message rejected due to: SPF fail - not authorized. (550 5.7.23) nor does it allow me to sign in with outlook IMAP

I do not know why this doesnโ€™t work, something to do with Microsoft. Iโ€™ve searched all over the place and couldnโ€™t find an answer.

๐Ÿ‘Ÿ Reproduction Steps

No response

๐Ÿ‹ DMS Version

v12.1.0

๐Ÿ’ป Operating System and Architecture

Ubuntu 22.04.3 LTS

โš™๏ธ Container configuration files

version: "3"
services:
  mailserver:
    image: ghcr.io/docker-mailserver/docker-mailserver:latest
    container_name: mailserver
    # Provide the FQDN of your mail server here (Your DNS MX record should point to this value)
    hostname: mail.kirakitsune.com
    env_file: mailserver.env
    environment:
      # Set SSL certificate type.
      - SSL_TYPE=letsencrypt

    # More information about the mail-server ports:
    # https://docker-mailserver.github.io/docker-mailserver/latest/config/security/understanding-the-ports/
    # To avoid conflicts with yaml base-60 float, DO NOT remove the quotation marks.
    ports:
      - "25:25"    # SMTP  (explicit TLS => STARTTLS, Authentication is DISABLED => use port 465/587 instead)
      - "143:143"  # IMAP4 (explicit TLS => STARTTLS)
      - "465:465"  # ESMTP (implicit TLS)
      - "587:587"  # ESMTP (explicit TLS => STARTTLS)
      - "993:993"  # IMAP4 (implicit TLS)
    volumes:
      - ./docker-data/dms/mail-data/:/var/mail/
      - ./docker-data/dms/mail-state/:/var/mail-state/
      - ./docker-data/dms/mail-logs/:/var/log/mail/
      - ./docker-data/dms/config/:/tmp/docker-mailserver/
      - /etc/localtime:/etc/localtime:ro
      - ./docker-data/certbot/certs/:/etc/letsencrypt/:ro
    restart: always
    stop_grace_period: 1m
    # Uncomment if using `ENABLE_FAIL2BAN=1`:
    # cap_add:
    #   - NET_ADMIN
    healthcheck:
      test: "ss --listening --tcp | grep -P 'LISTEN.+:smtp' || exit 1"
      timeout: 3s
      retries: 0

๐Ÿ“œ Relevant log output

No response

Improvements to this form?

No response

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 1
  • Comments: 15 (11 by maintainers)

Most upvoted comments

As Iโ€™ve mentioned and to make sure itโ€™s clear @outlook.com -> @kirakitsune.com SPF Fails @gmail.com, @proton.me, etc. -> @kirakitsune.con success @kirakitsune.com -> anything (incl. @outlook.com) success

Is outlook.com sending via IPv6 and the others via IPv4?

I have found today the solution alongside my partner (who did most of the work), but as @polarathene mentioned the policyd-spf was causing them issues in the past, this was also enabled on my end (which is by default), we disabled that and enabled ENABLED_RSPAMD, this did indeed solve the problem, I am surprised this is enabled by default even when the documentation stated

โ€œWe encourage everyone to prefer Rspamd via ENABLE_RSPAMD=1.โ€

and we sadly overlooked this part of the docs when going through it.

Sorry about not replying to all these replies, and coming back to it so late, but I much appreciated all your input.

I acknowledge that removing the AAAA record (so disabling ipv6 the easy way) solved this issue

Iโ€™d perform the following steps:

  1. Look at this article: https://learn.microsoft.com/en-us/microsoft-365/security/office-365-security/email-authentication-spf-configure?view=o365-worldwide
  2. Try to switch to Rspamd and disable the other SPF service

The fact that you cannot login via IMAP though leads me to believe there may be something more fundamentally wrong. Iโ€™d definitely check the DNS records.

Sorry forgot to answer about aliases, no none was created, simply used docker exec -ti <CONTAINER NAME> setup email add <NEW ADDRESS> to create the account.

OVERRIDE_HOSTNAME=mail.kirakitsune.com

I removed this

As Iโ€™ve mentioned and to make sure itโ€™s clear @outlook.com -> @kirakitsune.com SPF Fails @gmail.com, @proton.me, etc. -> @kirakitsune.con success @kirakitsune.com -> anything (incl. @outlook.com) success (also all exchange emails after doing more tests give the same results, @hotmail.com, @outlook.com, custom exchange mail, etc.)

I mentioned IMAP login with outlook because it failed due to authentication failure but worked fine in thunderbird.

My DNS TXT for spf is v=spf1 mx -all Iโ€™ve also tried ~all

Logs (debug, ip is my home ip hence the censor):

mailserver                | Oct 10 07:46:51 mail postfix/postscreen[703]: CONNECT from [ip]:35622 to [ip]:25
mailserver                | Oct 10 07:46:57 mail postfix/postscreen[703]: PASS NEW [ip]:35622
mailserver                | Oct 10 07:46:57 mail postfix/smtpd[713]: connect from unknown[ip]
mailserver                | Oct 10 07:46:58 mail postfix/smtpd[713]: Anonymous TLS connection established from unknown[ip]: TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)
mailserver                | Oct 10 07:46:59 mail policyd-spf[722]: 550 5.7.23 Message rejected due to: SPF fail - not authorized.
mailserver                | Oct 10 07:46:59 mail postfix/smtpd[713]: NOQUEUE: reject: RCPT from unknown[ip]: 550 5.7.23 <contact@kirakitsune.com>: Recipient address rejected: Message rejected due to: SPF fail - not authorized.; from=<email@outlook.com> to=<contact@kirakitsune.com> proto=ESMTP helo=<AUS01-ME3-obe.outbound.protection.outlook.com>
mailserver                | Oct 10 07:46:59 mail postfix/smtpd[713]: disconnect from unknown[ip] ehlo=2 starttls=1 mail=1 rcpt=0/1 quit=1 commands=5/6

This is what the outlook email says

Diagnostic information for administrators:

Generating server: SYBP282MB2429.AUSP282.PROD.OUTLOOK.COM
contact@kirakitsune.com
mail.kirakitsune.com
Remote server returned '550 5.7.23 <contact@kirakitsune.com>: Recipient address rejected: Message rejected due to: SPF fail - not authorized.'
Original message headers:

ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=mOJbPqkMfzFvhXkX7c9lEOHjM+VSXomsIRt3yxRyAkYyInlXHcCvItHwtQGrtD7RgQ4IS55eX0jwMYdYueRhvieKUuhF6tQxwYJDeelXrd1DKjW3QMnvfyaTBkgF+1bqOVqb0HfgF2abO/KCN4wBu1HFKwxNjfZRhMB2JRc4zxkXiqZ0idAve/owzHWr7ZGpkY2zQiza0QiDccddpQLJb2WOgIerJlzzrxWLBYAYGUENbM947f6HzgRmh2C0dyjLEEn1vGCmaE2v70JqFpwB7qVh2sGoKoxPzM3SmNzS4MBcAqt6vb5QSSnvDWCH/MtVYaiGPgjsPi7T77K4rxJVYg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=w/rCTAzj9fCNZhen/IzeZT5btP6I4ZyXHdZ8biyUUEY=;
 b=npXUK5NCiTn6hk2/lgfYZeYobDghwdWsilcNIG+87VGafBFuW3OVMeMHLxsto0zjCNUw9CRDnbYOo794YaaFZTnn+RJttVmu56ssj+wRzUkeBKu1pxGgoxl4Jxf92g23Yd/EMgeb1jSGafO29VU75LaIInDjJn7V5OfCiBl8hdpdRmCE8R6yBlTerqVRrXQbPUcG51+dQBGjCP5Bcey3VENaj8frBwM41g9N9j0K3cy5HFuEEYQtDWvnELfPeRYcxhlf6OrVy2X1knNnit6Knkejf/LteF3VKcQluD/wnhudP8DPnAhCoBzKLBbcI/nnu7g/h2kk8pX7kV7lBlcDvA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
 dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=w/rCTAzj9fCNZhen/IzeZT5btP6I4ZyXHdZ8biyUUEY=;
 b=ejdnV33kKwuAJJi9hbTaUlW2v2/4HJKdNZTOdc/KV5ZVvKQt+akabvdGa9n1ogREc0+5l2Okqdnne5RK/zhYLHOWn2M+p5ibG9o0tNXQSNZLEti2X7fIsPRV+lQbhR00rv0YXJThkmsobabeiaNGLVmbjUEPQAAYah4yGnbxUBTL+5QAPn+ro5agpzMNtoHXv/OLmcdK0FNaCw4w+ffQyxgzl6cepsYTK0qTuoLQQkYZFXCTiXd0B0JhtX8Aq0+XYVOgwXXbRrVHC5J7c9Y8TPwmF3KTio/npyAP5dYWSVSqGLkd7y0IlX458XBDCpLv3bsNjdwY9y2PrSHPWIVrtQ==
Received: from MEYP282MB3464.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:15e::5)
 by SYBP282MB2429.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:119::5) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Tue, 10 Oct
 2023 03:50:36 +0000
Received: from MEYP282MB3464.AUSP282.PROD.OUTLOOK.COM
 ([fe80::558d:b065:842:3ab]) by MEYP282MB3464.AUSP282.PROD.OUTLOOK.COM
 ([fe80::558d:b065:842:3ab%6]) with mapi id 15.20.6863.032; Tue, 10 Oct 2023
 03:50:36 +0000