Skip to content

Conversation

Copy link

Copilot AI commented Jan 19, 2026

Stalwart mail server fails with authentication errors on IMAP and returns 500 errors on CalDAV/CardDAV endpoints due to protocol implementation differences.

Changes

  • IMAP authentication: Check LOGINDISABLED capability and use SASL PLAIN authentication when LOGIN command is unavailable

    caps := c.Caps()
    if caps != nil && caps.Has(imap.CapLoginDisabled) {
        auth := sasl.NewPlainClient("", username, password)
        if err := c.Authenticate(auth); err != nil {
            // handle error
        }
    } else {
        // use LOGIN command
    }
  • CalDAV/CardDAV discovery: Add fallback to base URL path when WebDAV principal/home-set discovery fails

    calendars, err := c.FindCalendars(ctx, calendarHomeSet)
    if err != nil {
        // Fallback for servers with incomplete WebDAV discovery support
        calendars, err = c.FindCalendars(ctx, u.Path)
    }

All changes activate only when needed, maintaining compatibility with existing mail servers.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • git.sr.ht
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • https://api.github.com/repos/stalwartlabs/mail-server/issues
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)
  • todo.sr.ht
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

add fixes for stalwart mailserver


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 19, 2026 07:20
Use SASL PLAIN authentication when LOGINDISABLED capability is present.
Stalwart mail server may disable the LOGIN command and require AUTHENTICATE PLAIN instead.

Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Add fallback logic to handle cases where WebDAV discovery fails.
When FindCalendars or FindAddressBooks fails with the discovered home set,
try using the base URL path directly as a fallback. This fixes compatibility
with Stalwart mail server and other servers that may not fully implement
WebDAV principal/home-set discovery.

Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues in stalwart mailserver functionality Fix Stalwart mail server compatibility for IMAP, CalDAV, and CardDAV Jan 19, 2026
Copilot AI requested a review from GrassBlock1 January 19, 2026 07:30
@GrassBlock1 GrassBlock1 marked this pull request as ready for review January 19, 2026 07:36
Copilot AI review requested due to automatic review settings January 19, 2026 07:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds compatibility fixes for Stalwart mail server by addressing authentication and service discovery issues across IMAP, CalDAV, and CardDAV protocols.

Changes:

  • Add SASL PLAIN authentication fallback for IMAP when LOGIN command is disabled
  • Add CalDAV calendar discovery fallback to base URL path when standard discovery fails
  • Add CardDAV address book discovery fallback to base URL path when standard discovery fails

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
session.go Adds capability check for LOGINDISABLED and uses SASL PLAIN authentication when LOGIN is unavailable
plugins/caldav/caldav.go Adds fallback to base URL path when FindCalendars fails with calendar home set
plugins/carddav/plugin.go Adds fallback to base URL path when FindAddressBooks fails with address book home set
.gitignore Adds alps binary to ignored files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants