Skip to content

Conversation

@MunsMan
Copy link
Contributor

@MunsMan MunsMan commented Dec 5, 2025

Add optional userName fields to IMAP and SMTP submodules, allowing
different usernames for IMAP and SMTP servers. When not specified,
the account-level userName is used as a fallback.

This change updates all email programs (mbsync, msmtp, offlineimap,
getmail, neomutt, aerc, thunderbird, git) to use the protocol-specific
username when available.

Description

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.

  • Code tested through nix run .#tests -- test-all or
    nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

@teto
Copy link
Collaborator

teto commented Dec 5, 2025

could you share an example where it would be useful ? if we introduce complexity, we need to justify it

@MunsMan
Copy link
Contributor Author

MunsMan commented Dec 5, 2025

Sure! I'm personally facing this problem with an account provided by my university. The issue is that I can't manage a single account outside of Home-Manager, because every switch reverts my manual changes.

ItsShamed and others added 2 commits December 15, 2025 11:28
Add optional userName fields to IMAP and SMTP submodules, allowing
  different usernames for IMAP and SMTP servers. When not specified,
  the account-level userName is used as a fallback.

  This change updates all email programs (mbsync, msmtp, offlineimap,
  getmail, neomutt, aerc, thunderbird, git) to use the protocol-specific
  username when available.
@MunsMan MunsMan force-pushed the email/protocol-usernames branch from 0cb638e to 55173fd Compare December 15, 2025 10:29
default = null;
description = ''
The server username for SMTP. If `null`,
the account-level `userName` will be used.
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be simpler to inherit the top level userName and use defaultText = ${topLevelUsrName}.
I am not sure how feasible that is though. Shall one pass the name to the submodule for instance ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was initially my idea as well, but I struggled with getting the parent username. It might be a cleaner solution, as as it doesn't require the checking logic, as the username should always be defined.

But I don't now how to get the parent userName...

Copy link
Collaborator

@teto teto left a comment

Choose a reason for hiding this comment

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

the description of toplevel username should be updated to explain it can be overriden
Currently:

            The server username of this account. This will be used as
            the SMTP, IMAP, and JMAP user name.

The description for accounts.email.userName is updated to make it clear that this value is a default and can be overridden by the protocol-specific 'userName' options.
@MunsMan
Copy link
Contributor Author

MunsMan commented Dec 16, 2025

@teto Thanks, I missed that. I just updated the description,

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants