Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
99
views
How to make mv work with exotic directory names?
I created several scripts to move messages tagged via [notmuch][1] `notmuch` between `Maildir` directories. Having multiple accounts, I have some issues with the names of some directories mbsync created when syncing with gmail. Here is my typical `Maildir` structure for gmail accounts: ```sh gmail-u...
I created several scripts to move messages tagged via notmuch
notmuch
between Maildir
directories.
Having multiple accounts, I have some issues with the names of some directories mbsync created when syncing with gmail.
Here is my typical Maildir
structure for gmail accounts:
gmail-user2
├── [Gmail]
│ ├── Brouillons
│ │ ├── cur
│ │ ├── new
│ │ └── tmp
│ ├── Corbeille
│ │ ├── cur
│ │ ├── new
│ │ └── tmp
│ ├── Messages envoy&AOk-s
│ │ ├── cur
│ │ ├── new
│ │ └── tmp
│ ├── Spam
│ │ ├── cur
│ │ ├── new
│ │ └── tmp
│ └── Tous les messages
│ ├── cur
│ ├── new
│ └── tmp
└── Inbox
├── cur
├── new
└── tmp
When I run the following script:
function safeMove { s=${1##*/}; s=${s%%,*}; mv -f $1 $2/$s; }
echo Moving $(notmuch count --output=files tag:trash and tag:gmail-user2 and not path:/.*/Corbeille/ and not path:/.*/Trash/) trash-tagged mails to gmail-user2 Trash folder
for i in $(notmuch search --output=files tag:trash and tag:gmail-user2 and not path:/.*/Corbeille/ and not path:/.*/Trash/); do
safeMove $i ~/Maildir/gmail-user2/[Gmail]/Corbeille/cur
done
I have the following error:
mv: cannot stat '/home/user1/Maildir/gmail-user2/[Gmail]/Tous': No such file or directory
mv: cannot stat 'les': No such file or directory
How could I make mv
find the Tous les messages
directory?
EDIT:
According to the links provided in the comments I added double quotes:
function safeMove { s=${1##*/}; s=${s%%,*}; mv -f $1 $2/$s; }
for i in "$(notmuch search --output=files tag:trash and tag:gmail-user2 and not path:/.*/Corbeille/ and not path:/.*/Trash/)"; do
safeMove "$i" ~/Maildir/gmail-user2/[Gmail]/Corbeille/cur
done
Now I have the following error:
mv: target '/home/user1/Maildir/gmail-user2/[Gmail]/Corbeille/cur/1715687008.294831_40.user1-um450': No such file or directory
When find ~/Maildir/ -name 1715687008.294831_40.user1*
gives:
/home/user1/Maildir/gmail-user2/[Gmail]/Tous les messages/cur/1715687008.294831_40.user1-um450,U=40:2,FS
crocefisso
(193 rep)
May 15, 2024, 08:37 PM
• Last activity: May 16, 2024, 10:56 AM
0
votes
1
answers
274
views
Tagging mail with "notmuch" marks them as old
After syncing my local maildir inboxes with `offlineimap` and performing spam filtering and sorting using `fdm`+`bogofilter`, I tag the messages in the mail store using `notmuch`. Up until recently, I used the following shell code to tag and re-tag messages depending on certain criteria: ```sh notmu...
After syncing my local maildir inboxes with
offlineimap
and performing spam filtering and sorting using fdm
+bogofilter
, I tag the messages in the mail store using notmuch
.
Up until recently, I used the following shell code to tag and re-tag messages depending on certain criteria:
notmuch new
tr -s '\t' ' ' <<'END_BATCH' | notmuch tag --batch
-inbox +sent -- folder:/Sent/
-inbox +archive -- folder:/Archive/
-inbox +junk -- folder:/Junk/
+unsorted -- folder:/INBOX.Unsorted/
-unsorted -- not folder:/INBOX.Unsorted/
-unread -- tag:archive
+unread -- tag:unsorted
END_BATCH
This removes the inbox
tag from any message in a Sent
, Archive
or Junk
folder, while retagging the messages with the appropriate tags for those three folders. It then tags or untags messages depending on whether they are in an INBOX.Unsorted
folder (where I put messages that bogofilter
couldn't classify). Lastly, I ensure that archived messages are not tagged as unread
and that unsorted messages _are_ tagged as unread
.
This worked well.
Since I receive mail on five different accounts, I then also wanted to add tags like account-somename
, account-othername
etc. to messages, depending on the folder name:
notmuch new
tr -s '\t' ' ' <<'END_BATCH' | notmuch tag --batch
-inbox +sent -- folder:/Sent/
-inbox +archive -- folder:/Archive/
-inbox +junk -- folder:/Junk/
+unsorted -- folder:/INBOX.Unsorted/
-unsorted -- not folder:/INBOX.Unsorted/
-unread -- tag:archive
+unread -- tag:unsorted
+account-acc1 -- folder:/acc1/
+account-acc2 -- folder:/acc2/
+account-acc3 -- folder:/acc3/
+account-acc4 -- folder:/acc4/
+account-acc5 -- folder:/acc5/
END_BATCH
The tagging seems to be performed as expected, but a side-effect is that _new messages are marked as old_ (moved from the maildir's new
directory to the cur
directory). This in turn means mutt
won't detect the new messages in the inboxes (unless I set maildir_check_cur
in the mutt
configuration, which I don't think is a nice solution).
I don't know why or what I could do to stop this from happening.
My notmuch
configuration:
[database]
path=/home/myself/Mail/inboxes
[user]
name=myname
primary_email=me@example.com
other_email=otherme@example.com
[new]
tags=inbox;unread
[search]
[maildir]
syncronize_flags=true
[index]
header.List=List-Id
Kusalananda
(354298 rep)
Aug 30, 2023, 02:15 PM
• Last activity: Sep 1, 2023, 10:21 PM
2
votes
0
answers
726
views
neomutt+lieer: how to make deletion in neomutt sync properly to GMail?
I've recently migrated from mutt to neomutt, and have at the same time been moving from accessing my mailboxes live through IMAP to working with local frequently-synced copies, with a notmuch database. I have both an Outlook (work) address and a Gmail (personal) address. The outlook mail I'm syncing...
I've recently migrated from mutt to neomutt, and have at the same time been moving from accessing my mailboxes live through IMAP to working with local frequently-synced copies, with a notmuch database. I have both an Outlook (work) address and a Gmail (personal) address. The outlook mail I'm syncing with davmail and OfflineIMAP, and AFAICT it's working well. It's the GMail that's giving me grief; I'm syncing it with lieer which seems to for the most part do a good job, but I'm having a really difficult time with handling the process for message deletion. I can't find anyone else with this specific problem, so I'm guessing the answer is something stupidly simple I'm doing wrong.
I'm basically trying to follow more-or-less the workflow described here , although I'm not even trying to use lieer to send mail. The issue AFACT is that neomutt seems to follow one of a few behaviors with regard to what "deleting" a message means, and none of them seem to play quite right with the kind of thing lieeer wants to see to ensure a message is trashed cloudside. Here are the prospects I've looked at:
*
maildir_trash
set to "no", trash
unset. AFAICT, this setting makes neomutt unlink (as in, remove the associated file in the appropriate Maildirs) the message. Since lieer won't/can't push deletions (which is probably a good thing), that doesn't remove the messages cloudside on sync.
* maildir_trash
set to "no", trash
set. This is what I used to do, because IMAP connection to GMail provided a [Trash] folder. lieer seems to bring everything in with one monolithic maildir folder (called "mail", and within the lieer working directory), so unless there's a clever way to do this so that trash is a tag rather than a directory, it still doesn't seem to do what I want; changing the path to a message file seems like it would resemble a deletion to lieer, since it would take it out of the lieer sync path.
* maildir_trash
set to "yes". This seemed really pretty promising, because it seemed like it would set a flag rather than relocate the file, leaving it in the right directory but flagged as trash. Unfortunately, that flag never seems to make it to notmuch (this is apparently by design ) and thus never makes it to lieer. I could add another layer of byzantine automation to translate the flag myself, but I assume if that were necessary someone else would have talked about it.
A nonzero number of other people use lieer, notmuch, and neomutt, and nothing I've searched on suggests others have this problem, which suggests I've somehow broken something configured correctly by default? I include below an anonymized version of my .notmuch-config
and most of my .neomuttrc
(there's a lot of code to color various specific message patterns which I've elided, as it's probably not relevant):
[database]
path=/home/username/Private/.mail
[user]
primary_email=username@gmail.com
other_email=username@work.edu
[new]
tags=new
ignore=/.*[.](json|lock|bak)$/
[search]
[maildir]
synchronize_flags=true
[query]
workmail=folder:account.work/INBOX
gmail=folder:/account.gmail/ AND tag:inbox AND NOT tag:trash
virtual-mailboxes work "notmuch://?query=query:workmail"
virtual-mailboxes gmail "notmuch://?query=query:gmail"
virtual-mailboxes allmail "notmuch://?query=query:workmail OR query:gmail"
send2-hook '~f gmail.com' "source ~/.mutt/accounts/muttrc.gmail"
send2-hook '~f work.edu' "source ~/.mutt/accounts/muttrc.work"
reply-hook '~C work.edu' "source ~/.mutt/accounts/muttrc.work"
reply-hook '~C username.*@gmail.com' "source ~/.mutt/accounts/muttrc.gmail"
message-hook '!(~g|~G) ~b"^-----BEGIN\ PGP\ (SIGNED\ )?MESSAGE"' "exec check-traditional-pgp"
unignore date
alternates '^username'
source "~/.mutt_aliases"
set abort_noattach=ask-no
set abort_noattach_regex = "\\"
set abort_unmodified=ask-yes
set alias_file="~/.mutt_aliases"
set allow_ansi=yes
set arrow_cursor=yes
set askbcc=yes
set askcc=yes
set beep=no
set beep_new=yes
set certificate_file="~/.mutt_certs"
set confirm_append=no
set copy=yes
set crypt_auto_sign=yes
set edit_headers=yes
set editor="emacs -nw"
set folder="~/.mail"
set header_cache=~/.mutt/cache/headers
set history=20
set implicit_autoview=yes
set keep_flagged=yes
set mailcap_path="~/.mailcap"
set maildir_trash=yes
set mbox_type="Maildir"
set message_cachedir=~/.mutt/cache/bodies
set mime_forward=ask-no
set move=no
set nm_default_uri = "notmuch:///home/username/.mail"
set pager_stop=yes
set pgp_clear_sign_command="gpg --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_decode_command="gpg --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
set pgp_decrypt_command="gpg --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
set pgp_encrypt_only_command="/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
set pgp_sign_command="gpg --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_encrypt_sign_command="/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_good_sign="^\\[GNUPG:\\] GOODSIG"
set pgp_import_command="gpg --no-verbose --import %f"
set pgp_list_pubring_command="gpg --no-verbose --batch --quiet --with-colons --list-keys %r"
set pgp_list_secring_command="gpg --no-verbose --batch --quiet --with-colons --list-secret-keys %r"
set pgp_sign_as="0xXXXXXXXX"
set pgp_timeout=1800
set pgp_verify_command="gpg --status-fd=2 --no-verbose --quiet --batch --output - --verify %s %f"
set pgp_verify_key_command="gpg --verbose --batch --fingerprint --check-sigs %r"
set print_command="enscript -Pkether/2 --margins=:::72 --header='Page $% of $='
set realname = "My Real Name"
set record="+sent-mail"
set signature="$HOME/.signatures/sign|"
set sort = threads
set sort_aux = last-date-received
set spool_file = allmail
set text_flowed=yes
Many thanks to anyone who can help!
Jake Wildstrom
(61 rep)
May 15, 2023, 04:47 PM
0
votes
1
answers
465
views
How do I fix my neomuttrc syntax?
I've had Neomutt setup and working great for a while now but at some point I started seeing an error on launch that I'd like to finally fix. The error says: Error in /home/amanda/.config/neomutt/neomuttrc, line 23: Binding '\\' will alias '\' Before, try: 'bind pager \ noop' https://neomutt.org/guid...
I've had Neomutt setup and working great for a while now but at some point I started seeing an error on launch that I'd like to finally fix. The error says:
Error in /home/amanda/.config/neomutt/neomuttrc, line 23:
Binding '\\' will alias '\' Before, try: 'bind pager \ noop' https://neomutt.org/guide/configuration.html#bind-warnings
Warning in /home/amanda/.config/neomutt/neomuttrc, line 24:
source: errors in /home/amanda/.config/neomutt/neomuttrc
My goal is to have
\\
open a notmuch query to search my whole mail directory, while /
just searches the list or query that is open (so if I'm looking at INBOX, /
will open a prompt to search my INBOX and \\
will open a prompt to search all mail.
The error suggests adding bind pager \ noop
but line 23 says exactly that.
What is the right way to set my neomuttrc
so that \\
opens a query prompt?
My complete neomuttrc
file in case there's something else I'm missing:
source ~/.config/neomutt/pass.sh|
set smtp_url = "smtp://myself@example.com@mail.example.com:587/"
set smtp_pass = $my_pass
set ssl_force_tls = yes
set from = "myself@velociraptor.info"
set realname = "Myself"
set signature = "~/.config/neomutt/signature"
set status_format = "%n new | %M in %f [%v]."
set xterm_set_titles = yes
# notmuch
set nm_default_uri="notmuch:///home/myself/Mail" # path to the maildir
set spoolfile = ~/Mail/INBOX
set record = ~/Mail/INBOX.Sent
set postponed = ~/Mail/INBOX.Drafts
set mbox_type = Maildir
set folder = ~/Mail/
# notmuch bindings
bind pager \ noop
macro index,pager \\\\ "" # looks up a hand made query
macro index A "+archive -unread -inbox\\n" # tag as Archived
macro index I "-inbox -unread\\n" # removed from inbox
macro index S "-inbox -unread +junk\\n" # tag as Junk mail
macro index + "+*\\n" # tag as starred
macro index - "-*\\n" # tag as unstarred
# macro pager `
# ctrl u searches for URLs
macro pager \cu |urlview\n
# Remap bounce-message function to “B”
bind index B bounce-message
# show the year via http://www.sendmail.org/~ca/email/mutt/manual-6.html#index_format
set index_format = "%4C %Z %{%b %d %Y} %-15.15L (%?l?%4l&%4c?) %s"
## Save Hooks
save-hook '~s [Rr]eceipt' =INBOX.receipts
save-hook '~s order\ confirmation' =INBOX.receipts
save-hook '~s authorized\ a\ payment' =INBOX.receipts
save-hook '~e Venmo' =INBOX.receipts
save-hook . =INBOX.Archives.%[%Y]
## Addressing
macro pager,index a "khard add-email" "add the sender address to khard"
set query_command= "khard email --parsable %s"
bind editor complete-query
bind editor ^T complete
set mailcap_path = ~/.config/mailcap
set print_command="/home/amanda/.config/neomutt/print_unicode.sh"
Amanda
(1818 rep)
Feb 20, 2021, 12:04 AM
• Last activity: Feb 28, 2021, 11:24 AM
4
votes
1
answers
1087
views
How can I find out/display the mailbox that a particular message is in with neomutt+notmuch?
I am using notmuch together with neomutt. I am using the recommended setup, i.e. I can search for messages matching certain criteria with `/` and results are shown in a virtual folder directly in mutt, which is nice. I keep all of my email in different IMAP mailboxes, i.e. INBOX is - in theory - emp...
I am using notmuch together with neomutt. I am using the recommended setup, i.e. I can search for messages matching certain criteria with
/
and results are shown in a virtual folder directly in mutt, which is nice. I keep all of my email in different IMAP mailboxes, i.e. INBOX is - in theory - empty.
Because of this, quite often, I would like to know in which mailbox a particular message is that I found through notmuch. Is there a way to do so? Or, even better, is there a way to directly jump to the corresponding mailbox and thread from the search results?
Thanks a lot for your help in advance!
andyknownasabu
(41 rep)
May 9, 2017, 02:23 PM
• Last activity: Nov 20, 2020, 04:41 PM
2
votes
2
answers
914
views
How to get the notmuch message-id and thread-id from a maildir message filename already in the notmuch db?
Let's assume that I make a notmuch query that returns files: $ notmuch search --output=files tag:inbox from:love This returns a list of files, pointing to Maildir messages. Now I pick one of these files (already in the notmuch database), for instance with FILENAME=$(notmuch search --output=files tag...
Let's assume that I make a notmuch query that returns files:
$ notmuch search --output=files tag:inbox from:love
This returns a list of files, pointing to Maildir messages. Now I pick one of these files (already in the notmuch database), for instance with
FILENAME=$(notmuch search --output=files tag:inbox from:love | fzf)
and I would like to get its message-id and thread-id in the notmuch database. __From the variable $FILENAME, I would like to find the message-id in notmuch.__
A very sloppy way to do this is to parse the file, read the headers from/subject/date and make a notmuch query `
notmuch search from:{...} subject:{...} date:{..}
`. But since the filenames are already stored in the database, I guess there should be a canonical and robust way to obtain the mesage-id from the filename.
Thanks!
jlewk
(131 rep)
Aug 23, 2020, 08:38 PM
• Last activity: Aug 26, 2020, 10:39 AM
1
votes
1
answers
488
views
Multiple accounts with afew
I've recently started using `Notmuch`. One thing I am missing is to setup `afew` to move messages between folders after tagging them with `Notmuch`. It all works fine with just one account under `~/Mail`, however, I want to operate on 3 separate accounts which would be `~/Mail/Account1` `~/Mail/Acco...
I've recently started using
Notmuch
. One thing I am missing is to setup afew
to move messages between folders after tagging them with Notmuch
. It all works fine with just one account under ~/Mail
, however, I want to operate on 3 separate accounts which would be ~/Mail/Account1
~/Mail/Account2
~/Mail/Account3
How do I configure afew
to move messages based on tags in specific accounts? afew
just does not see anything in the subfolders/subaccounts.
Sample config:
[MailMover]
folders = Account1/INBOX Account2/INBOX Account3/INBOX
Account1/INBOX = 'tag:spam':spam
Account2/INBOX = 'tag:spam':spam
Account3/INBOX = 'tag:spam':spam
Obiviously Account1/INBOX
is not a valid variable name. Perhaps afew
cannot deal with multiple accounts?
Damian Chrzanowski
(176 rep)
Aug 21, 2017, 09:29 AM
• Last activity: Apr 5, 2019, 10:41 PM
2
votes
1
answers
568
views
Why does notmuch ignore my wildcards?
My read of the [notmuch search documentation](https://notmuchmail.org/manpages/notmuch-search-terms-7/) suggests that I should be able to use wildcards in searches, but that doesn't seem to be the case. For instance, I have my mail archives organized into folders by year. If I search for... notmuch...
My read of the [notmuch search documentation](https://notmuchmail.org/manpages/notmuch-search-terms-7/) suggests that I should be able to use wildcards in searches, but that doesn't seem to be the case. For instance, I have my mail archives organized into folders by year. If I search for...
notmuch search folder:INBOX.Archives.*
I get no results, but if I search for a specific year, I get what I expected -- the list of messages in that folder:
notmuch search folder:INBOX.Archives.2007
Similarly,
tag:inbo*
gets nothing. tag:inbox
gets plenty.
What am I missing here?
Amanda
(1818 rep)
Apr 6, 2016, 09:28 PM
• Last activity: Mar 20, 2019, 09:43 AM
4
votes
1
answers
879
views
How can I search gpg-encrypted email with notmuch-mutt?
I'm using `mutt`, with [`notmuch-mutt`][1] indexing the mail. I have a macro defined in `mutt` to search multiple mailboxes, using `notmuch`'s integration (as suggested in the `man` page). macro index \ " set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key \ notm...
I'm using
mutt
, with notmuch-mutt
indexing the mail. I have a macro defined in mutt
to search multiple mailboxes, using notmuch
's integration (as suggested in the man
page).
macro index \
"set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\
notmuch-mutt -r --prompt search --decrypt\
echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results
\
set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \
"notmuch: search mail"
I also have GPG-encrypted email. mutt
can unencrypt these fine, and its internal search works perfectly on the encrypted emails. However, notmuch-mutt
fails to search these properly. Notmuch 0.6 (from 2011) apparently supports GPG, however this doesn't work for me out of the box. I'm running Notmuch 0.20.2. Is there a way to search encrypted mails using notmuch-mutt
?
Sparhawk
(20499 rep)
Oct 10, 2015, 01:31 PM
• Last activity: Mar 20, 2018, 11:53 PM
2
votes
1
answers
453
views
How do I tell notmuch to scan folders for new messages?
I'm using `mutt-kz`, `offlineimap` and `notmuch` to read and search my email. I'm syncing between two computers so I need to store things in folders so that some structure is preserved, but I've discovered that when my folders aren't getting indexed. Specifically, I read a message from "Angela" at w...
I'm using
mutt-kz
, offlineimap
and notmuch
to read and search my email. I'm syncing between two computers so I need to store things in folders so that some structure is preserved, but I've discovered that when my folders aren't getting indexed. Specifically, I read a message from "Angela" at work and save it to a folder. And then later, at home, I search for "Angela" and I do not see the message I'm looking for. The one I _know_ I read yesterday on my office computer. I look in the folder I saved it to and it is there.
So it seems like what is happening is that previously read messages (so no bearing the "New" flag) are are not being indexed by Notmuch if they aren't in the inbox.
Is this expected behavior? How do I tell notmuch
to index all the mail that offlineimap
just downloaded?
Amanda
(1818 rep)
Apr 18, 2016, 07:45 PM
• Last activity: Apr 18, 2016, 08:17 PM
Showing page 1 of 10 total questions