You are not logged in.
Hi Arch buddies !
I have decided to move to neomutt to manage my emails instead of mu4e in emacs. I'm struggling with 2 last issues:
1. When I send an email with attachments, the attached files are automatically renamed ATTxxx when they reach the recipients' mailboxes. How can I tell neomutt to use the filenames as names for my attachments?
2. I'm using neomutt with 2 email accounts and a virtual folder set up with notmuch. When replying to an email from this virtual folder, the sent email is copied to the Sent folder of the email account I've received the email from. How can I have this email copied to another folder? I've tried to play with set record, folder-hooks, and reply-hook with no success. I'm sure I'm just missing something stupid.
Thanks in advance !
Last edited by guilouv (2022-03-26 18:36:02)
Offline
For #1 that is not the default and should not happen - it sounds like the result of a problematic setting. The second is an issue with "record" which is the setting you should use - but it sounds like you have it set to a relative path where you may want to set it to an absolute path (or relative at least to the toplevel).
For both it'd be helpful if you could post your complete config file. Redact any passwords, of course, and also your actual email address if you'd like - but please clearly indicate which bits are redactions.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for jumping in !
Here are the config files (except my keybindings and non-relevant mbsyncrc and mailcap files). I've replaced my username with user and my 2 accounts names with account1 and account2.
File: ~/.mutt/muttrc
cd ~/Documents
set abort_unmodified = yes
set ascii_chars
set attach_keyword = "\\<attach(|ed|ments?)\\>"
set attribution = "On %d, %n wrote:"
set autoedit
set auto_tag
set collapse_all = yes
set confirmcreate
set editor = "nvim"
set envelope_from = yes
set fast_reply
set fcc_attach = yes
set folder = ~/.mail
set forward_decode
set forward_format = "[%a: %s]"
set forward_quote
set header
set header_cache
set header_cache_compress_method = "zstd"
set header_cache_compress_level = 22
set help = no
set hostname = ""
set implicit_autoview = yes
set include
set index_format = "%-3.1M %-1.1S %-16.16@date@ %-35.32F %s %* %b"
index-format-hook date "~N" "* * %[%H:$M] * *"
index-format-hook date "~d<1d" "%[%H:%M]"
index-format-hook date "~d<1y" "%[%b %d @ %H:%M]"
index-format-hook date "~A" "%[%m/%d/%y @ %H:%M]"
set ispell = "aspell -e -c"
set mailcap_path = "~/.mailcap"
set mail_check = 60
set mail_check_stats = yes
set mark_old = yes
set markers = no
set message_cachedir = ~/.mutt/cache/bodies
set mbox = ~/.mail
set mbox_type = Maildir
set mime_forward = no
set new_mail_command = "/bin/notify-send %n 'new emails'"
set nm_default_url = "notmuch:///home/user/.mail"
set nm_query_type = threads
set nm_record = yes
set noprompt_after
set nosave_empty
set pager_format = "%f"
set pager_index_lines = 20
set print_command = /bin/false
set query_format = "%t %-50.50a %n"
set quote_regexp = "^ *[a-zA-Z]*[>:#}]"
set read_inc = 25
set realname = "MyName"
set recall = yes
set reply_to
set reply_regexp = "^(re:[ \t]*)+"
set reverse_name
set shell = "/bin/zsh"
set sidebar_folder_indent= yes
set sidebar_format = "%D%* %?N? [%N]? %S"
set sidebar_indent_string= " "
set sidebar_non_empty_mailbox_only = yes
set sidebar_divider_char = " | "
set sidebar_short_path = yes
set sidebar_sort_method = alpha
set sidebar_visible = no
set sidebar_width = 50
set sig_dashes = no
set sig_on_top = yes
set sleep_time = 0
set smart_wrap
set sort = last-date
set sort_aux = date
set sort_browser = alpha
set status_format = "%f"
set status_on_top
set tilde
set tmpdir = ~/tmp
set nouse_domain
set query_command = "abook --mutt-query '%s'"
set use_from
set use_threads = reverse
set visual = nvim
set wait_key = no
set wrap = 80
set write_inc = 25
ignore *
unignore from: subject to cc mail-followup-to date x-mailer x-url
unhdr_order *
hdr_order from to cc subject date
alternative_order multiparse/alternative text/calendar text/html text/plain
auto_view application/ics
auto_view text/html
folder-hook Account1 'source ~/.mutt/Account1'
folder-hook Account2 'source ~/.mutt/Account2'
folder-hook notmuch 'source ~/.mutt/notmuch'
reply-hook "~C user@account1.com" "source ~/.mutt/Account1"
reply-hook "~C user@account2.com" "source ~/.mutt/Account2"
source "~/.mutt/color"
source "~/.mutt/bind"
source "~/.mutt/Account1"
source "~/.mutt/Account2"
source "~/.mutt/notmuch"File:~/.mutt/Account1
set folder = ~/.mail
set spoolfile = "+/Account1/Inbox"
set record = "+/Account1/Inbox"
set postponed = "+/Account1/Drafts"
unset imap_passive
set imap_check_subscribed
set sendmail = "/usr/bin/msmtp -a Account1"
set from = user@account1
set copy = no
set signature = "~/.mutt/casual_sig
alternates user@account1
color indicator brightwhite default
color index_author brightcyan default "! ~v ~>(~A)"
color status brightcyan default
macro index bi "<change-folder>+/Account1/Inbox<Enter>"
macro index bd "<change-folder>+/Account1/Drafts<Enter>"
macro index bs "<change-folder>+/Account1/Sent<Enter>"
macro index bt "<change-folder>+/Account1/Trash<Enter>"
mailboxes `base="\/home\/user\/.mail"; for file in $(fd -t directory . ~/.mail/Account1 | sed '/cur\|new\|tmp\|Account1/d'); do box=$(echo "$file" | sed "s/$base//"); echo -n "+$box "; done`File:~/.mutt/Account2
set folder = ~/.mail
set spoolfile = "+/Account2/Inbox"
set record = "+/Account2/Inbox"
set postponed = "+/Account2/Drafts"
unset imap_passive
set imap_check_subscribed
set sendmail = "/usr/bin/msmtp -a Account2"
set from = user@account2.com
set copy = no
set signature = "~/.mutt/formal_sig
send-hook "~t @account2" set signature=~/.mutt/casual_sig
alternates user@account2
color indicator brightwhite default
color index_author brightmagenta default "! ~v ~>(~A)"
color status brightmagenta default
macro index bi "<change-folder>+/Account2/Inbox<Enter>"
macro index bd "<change-folder>+/Account2/Drafts<Enter>"
macro index bs "<change-folder>+/Account2/Sent<Enter>"
macro index bt "<change-folder>+/Account2/Trash<Enter>"
mailboxes `base="\/home\/user\/.mail"; for file in $(fd -t directory . ~/.mail/Account2 | sed '/cur\|new\|tmp\|Account2$\|Archives\|Sync\ Issues\|Working\ Set\|Unsent\ Messages/d'); do box=$(echo "$file" | sed "s/$base//"); echo -n "+$box "; done`Filename:~/.mutt/notmuch
set folder = ~/.mail
set virtual_spoolfile = yes
virtual-mailboxes "Today" "notmuch://?query=date:0d"
virtual-mailboxes "Unread" "notmuch://?query=tag:unread or tag:old not folder:Account1/Drafts not folder:Account2/Drafts"Last edited by guilouv (2022-03-25 00:24:06)
Offline
First, I'd drastically simplify all of that. You have many variables set redundantly in several places. As just a couple examples, theres no need to rebind all the same bindings in both account files (just use relative paths in the folder to change to). The colors are also duplicated, as is the "folder" setting along with others.
But aside from that the first thing that jumps out at me is that you source each account config file in at least three ways, a folder-hook which makes sense, a reply-hook which is fine but depending on your use may not be needed, and then unconditionally at the end of your primary muttrc which makes no sense at all. When your muttrc is read you don't set "record", but then the Account1 config is unconditionally sourced and it sets "record" to "~/.mail/Account1/Inbox" then the Account2 config is also unconditionally sourced and overrides this setting with a new setting for "record" of "~/.mail/Account2/Inbox". Then of course there's the fact that neither of these are likely the setting you actually want as setting "record" to Inbox is very very odd - do you really want copies of your SENT mail in Inbox (as opposted to +/Sent or +/sent ...)?
But to address the actual problem, it's pretty clear: your ~/.mutt/notmuch file which is sourced for that "virtual folder" doesn't set "record" at all. So of course it just remains set at whichever location it was last set to ... which would be whichever of Account1 or Account2 was most recently sourced.
Overall this really looks like a patchwork of inherited config bits that you threw together without knowing what they mean. I'd strongly advise starting from scratch and only including settings in your config that you understand.
EDIT: I wasn't able to address the attachment naming issue - no obvious sources of that problem jumped out at me. But if starting with a minimal config resolves that issue, you'll know it was from one of your settings.
Last edited by Trilby (2022-03-25 00:35:18)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks, I have to admit that I'm still working on it so I indeed need to clean everything when done.
That being said, you mention redundancy in binding and colors for example. If you are talking about the config files for Account1 and Account2, they are actually not real duplicates. Commands look similar but they each act on the specific account (like inbox colors are different for both accounts and the same goes for binding to jump to inbox). If you have a more "generic" command I could use based on a variable or something I'd like to hear about that.
You're totally right about the unconditional source, I completely missed it.
I know it looks weird but yes it's my intent to copy my sent files to Inbox since I don't want to move my incoming mails to a folder and then switch to the sent folder to move my replies to these emails to the same folder. It'll be easier to move everything from the same folder (i.e. the Inbox).
But to address the actual problem, it's pretty clear: your ~/.mutt/notmuch file which is sourced for that "virtual folder" doesn't set "record" at all. So of course it just remains set at whichever location it was last set to ... which would be whichever of Account1 or Account2 was most recently sourced.
I've actually tweaked everything because now when replying from the virtual folder it will place copies in the correct account but in the Sent folder which I didn't reference anywhere. Setting the record setting in the virtual folder config file had no effect and when I've started the behavior was obviously like you said: applying the last account config. I'll dig into that and try to play more with the record setting.
Also, the Fcc field reads correctly so it may be overwritten somehow when the message is being sent.
Overall this really looks like a patchwork of inherited config bits that you threw together without knowing what they mean. I'd strongly advise starting from scratch and only including settings in your config that you understand.
I've started from a very minimalist config and then built everything around it. I've also read the neomutt (which is a lot of pages) so this entire mess is my own... which means that I did a terrible work from what you're saying. Awesome, after all these years I suck at writing a stupid config file and look like idiot !
I definitely need to clean it but I thought that the "set" options were already good. Anyway, I'm going back to working on that.
Thanks for taking time to look at this mess. I'll work on it and try to fix it again...
Still need to figure out the attachment issue though.
Last edited by guilouv (2022-03-25 01:26:00)
Offline
Thanks, I have to admit that I'm still working on it so I indeed need to clean everything when done.
Clean first. Solving problems will be much easier then.
like inbox colors are different
Two out of the three are different, but the first is identical.
same goes for binding to jump to inbox). If you have a more "generic" command I could use based on a variable or something I'd like to hear about that.
Like I suggested, relative paths. Have your macro for "bd", for example, switch to "../Drafts" or similar. This will then work for whichever account you are in.
it's my intent to copy my sent files to Inbox since I don't want to move my incoming mails to a folder and then switch to the sent folder to move my replies to these emails to the same folder.
Moving? Why are you moving anything?
it will place copies in the correct account but in the Sent folder which I didn't reference anywhere.
That is the default. So if you don't set "record" anywhere, that's where they will go. Though you set it in several places ... but again, the settings are so spaghetti-coded that it's hard to know what to expect to happen.
so it may be overwritten somehow when the message is being sent.
Again, not too surprising given the complexity of how many different hooks and bindings (re)source files with many different settings in them.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I'll try to work with relative paths, that sounds the way to go.
Moving? Why are you moving anything?
Because I have so many projects for my work I need to keep organized/separated. So I have one folder per project and this is where I need to move the emails.
Overall, I just did the worst job ever with this config file and I need to clean and rework on it. Back to the start. Take home message: I did not learn anything in >20 years of Arch.
Thanks for your help.
Offline
A bit off topic, but if you are using notmuch, why create folders and move mails around when you can just use tags for projects?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Because I'm new to notmuch as well... and as stupid with it as I am with neomutt.
I need to have my folders organization replicated on the imap side as well and thought that changing stuff in notmuch would not do so.
Offline
I have clean things. I hope I did not miss anything. I was actually glad to realize that the mess was pretty much what I was expecting for something written in few hours from (almost) scratch and just after jumping into neomutt/notmuch.
The only real issue I should not have made is really this unconditional sourcing that I forgot at the end of the muttrc file.
File:~/.mutt/muttrc
... I did not change the set options section but here are the changes made below it ...
ignore *
unignore from: subject to cc mail-followup-to date x-mailer x-url
unhdr_order *
hdr_order from to cc subject date
set spoolfile = "+/Inbox"
set record = "+/Sent"
set postponed = "+/Drafts"
virtual-mailboxes "Today" "notmuch://?query=date:0d"
virtual-mailboxes "Unread" "notmuch://?query=tag:unread or tag:old not folder:Drafts"
alternative_order multiparse/alternative text/calendar text/html text/plain
auto_view application/ics
auto_view text/html
folder-hook Account1 'source ~/.mutt/Account1'
folder-hook Account2 'source ~/.mutt/Account2'
folder-hook notmuch 'source ~/.mutt/notmuch'
source "~/.mutt/color"
source "~/.mutt/bind"File:~/.mutt/Account1
set folder = ~/.mail/Account1
set sendmail = "/usr/bin/msmtp -a Account1"
set from = user
set signature = "~/.mutt/casual_sig
alternates user
color index_author brightcyan default "! ~v ~>(~A)"
color status brightcyan default
mailboxes `base="\/home\/user\/.mail\/Account1"; for file in $(fd -t directory . ~/.mail/Account1 | sed '/cur\|new\|tmp\|Account1$/d'); do box=$(echo "$file" | sed "s/$base//"); echo -n "+$box "; done`File:~/.mutt/Account2
set folder = ~/.mail/Account2
set sendmail = "/usr/bin/msmtp -a Account2"
set from = user
set signature = "~/.mutt/formal_sig
alternates user
color index_author brightmagenta default "! ~v ~>(~A)"
color status brightmagenta default
mailboxes `base="\/home\/user\/.mail\/Account2"; for file in $(fd -t directory . ~/.mail/Account2 | sed '/cur\|new\|tmp\|Account2$\|Archives\|Sync\ Issues\|Working\ Set\|Unsent\ Messages/d'); do box=$(echo "$file" | sed "s/$base//"); echo -n "+$box "; done`File:~/.mutt/notmuch
set folder = ~/.mail
set virtual_spoolfile = yesFor simplicity - and while learning more about notmuch - I have set the record value to +/Sent.
Both issues (see definitions in the first post) still persist. Hopefully the config files are now clear enough so we can start some troubleshooting.
Last edited by guilouv (2022-03-25 20:37:09)
Offline
Just an update: I've found another way to manage my sent emails so let's forget the issue #1.
Looking forward to any idea Re: the attachment naming issue.
Offline
Are you sure the attachments are going out from neomutt with those names? Are you sending from / to / through any MS mail servers (msn, hotmail, exchange, office365, etc)? The ATTxxxx format is a common edit that obnoxious mail servers can make to attachments they view as untrusted and this is known to happen with MS exchange mail servers.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I upload the attachment in neomutt and send them without editing anything.
I am indeed using a gmail and an exhange mailbox so that may be it. Actually, I have this issue with my exchange account. Now, I've just tried with my gmail account and... it's worth. My attachment does not reach the recipient mailbox, just the text. FYI, I've made several tests with a docx or a pdf file. In every cases, I can see and open the attachments from my sent emails.
Edit1: I use a script to send my emails as both plain text and html. Looks like the call to the neomutt command <group-alternatives> is responsible for the attachments weird behaviors if it's used after attaching the files to the mail. In other words, I have no issues if I create the 2 versions (plain and html) and then attach the files before sending the mail. I'm making progress ^^
Since I unfortunately need to send my professional emails as html because of people who will otherwise complain, I now need to find a way to have this work using a single keybinding because it's not very efficient to have to convert the text, then attach the files, and finally send the mail.
Edit2: There's no better help than having others asking questions so you suddenly point out what you missed for hours/days/weeks. Here is the command I use to send my mails: <first-entry>| sh ~/.mutt/script_to_convert_plain_in_html<Enter><attach-file>/tmp/converted.html<Enter><tag-entry><previous-entry><tag-entry><group-alternatives><send-message>
If it works fine for emails with no attachments, the correct command in all cases requires to replace the <previous-entry> bit with <first-entry>. Indeed, the converted html file is appended as the last attachment, the plain text is on top of the list and there may be any attachments in between.
Topic closed.
Last edited by guilouv (2022-03-26 18:37:09)
Offline