[neomutt-users] How to automatically inform neomutt of all mailboxes?

Sam Kuper sampablokuper at posteo.net
Sat May 23 02:35:23 CEST 2020


On Fri, May 22, 2020 at 03:53:25PM +0100, Krishnakumar Gopalakrishnan wrote:
> I am currently using neomutt v2020-05-01, and my institutional email
> provider is Office365. I sync my mail using msmtp and a cronjob.

IIUC, msmtp will act as a sendmail substitute (i.e. it will accept
outgoing emails from Mutt and send them to Office365.  That's all well
and good, but it doesn't tell us anything about how you handle inbound
emails or the outbound emails that Office365 might store copies of in
your Sent Items mailbox.

In what follows, I assume that your mailboxes' contents are being
retrieved from the Office365 server via POP3 or IMAP4 and copied into
local Maildirs as indicated by your diagram below.  I also assume that
`folder` is set correctly in your .muttrc, to point to the root of the
tree in your diagram.

I also assume that the sub-mailboxes in your diagram below (e.g.
"Admin_stuff") are genuine Maildirs and the only reason their
{cur,new,tmp} folders aren't shown above is due to the `-L 2` parameter
passed to `tree`.

> [..] PS: Here is a snapshot of the hierarchy of my mail folder (output
> of tree -L 2)
> 
> .
> ├── Archive
> │   ├── cur
> │   ├── new
> │   └── tmp
> [..]
> ├── INBOX
> │   ├── Admin_Stuff
> [..]
> │   ├── cur
> │   ├── new
> │   └── tmp
> [..]
>
> What would be the suitable "named-mailboxes" or "mailboxes" command to
> correctly fetch the entire hierarchy of valid inbox folders
> automatically?

I would recommend:

1.  For an easier life, adopt the Maildir++ directory structure
    (~/Maildir/.folder.subfolder/) instead of the "fs" (aka "nested")
    directory structure (~/Maildir/folder/subfolder/) that you are
    currently using.  This will avoid you needing to increase the
    `maxdepth` parameter below and to invent additional rules to exclude
    unwanted directories.

2.  After you have adopted the Maildir++ directory structure, then try
    the following `mailboxes` line in your .muttrc:

        mailboxes `find "$MAILDIR" -maxdepth 2 -type d -name cur -printf "+'%P'\n" | sed "s/\/cur'/'/g" | sed "s/'cur'/'.'/g" | LC_COLLATE=C sort | tr '\n' ' '`

    Here's the same thing, split over multiple lines for clarity, in
    case the above gets badly line-wrapped in transit.

        mailboxes \
            `find "$MAILDIR" \
                -maxdepth 2 \
                -type d \
                -name cur \
                -printf "+'%P'\n" \
            | sed "s/\/cur'/'/g" \
            | sed "s/'cur'/'.'/g" \
            | LC_COLLATE=C sort \
            | tr '\n' ' '`

Good luck!

-- 
A: When it messes up the order in which people normally read text.
Q: When is top-posting a bad thing?

()  ASCII ribbon campaign. Please avoid HTML emails & proprietary
/\  file formats. (Why? See e.g. https://v.gd/jrmGbS ). Thank you.


More information about the neomutt-users mailing list