Re: Save external imap emails to a local maildir folder
* Piet [2022-02-19 00:17]: > Dear List, > > I use Mutt with two external imap accounts. > At the moment the only thing I miss by using Mutt is to filter and move > emails to local folders. > To be honest, I red a lot of howtos but do not understand, how to > deal with folders. That is exactly what I do all the time, I read IMAP and save to Maildir. I think these are main settings on my side to save it as Maildir: set folder=/home/data1/protected/Maildir set mbox_type=Maildir # Save by email address set save_name=yes set save_address=yes The above makes sure that I save emails by the correspondent's email addres, if correspondent is per...@example.com then it gets saved in ~/Maildir/per...@example.com and then all conversations sent to per...@example.com and received from per...@example.com may be easily found in ~/Maildir/per...@example.com I have set one key to open all previous conversations related to the per...@example.com easily > First of all I like to save emails from external imap accounts to a > local maildir folder. But I do not want to use additional software > like mbsync or offlineimap. One by one or tagged emails, all that can be saved as explained above. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Default path for saving attachments?
* José María Mateos [2022-02-17 20:42]: > Hi all, > > When I want to save an attachment, the default path is the path where mutt > was launched (typically my home folder). I'd like to know if there's any > config variable to set the destination folder for saved attachments. I know > the workaround is to start mutt in a different place, but I'd prefer the > config option. set attach_save_dir="~/Downloads/mutt-attachments" -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Slightly OT: I'm looking for a tool to merge maildirs
* Chris Green [2022-01-23 13:59]: > This is a bit off topic for mutt specifically but it's about doing > things to the mail I read using mutt, so it's not *very* OT. :-) > > I'm looking for a way to keep an archive (as in a maildir hierarchy) > of *all* my mail into which I can merge my current (S[aved] in to > using mutt) maildir hierarchy. > > This isn't just a straight copy of everything as there will be some > (quite a lot of) overlap. I.e. I will keep mail dating back to (say) > 2010 in my current, seen directly by mutt, mail hierarchy and I will > want to merge this into the archive at (say) monthly intervals so > there will be some years of E-Mails that are in both hierarchies. > > Both hierarchies will be on the same computer so it isn't an IMAP > synchronisation tool I'm looking for. These are just directory trees > full of maildir mailboxes. > > I will, if necessary, write it myself, probably in Python but I don't > want to reinvent the wheel if I don't have to. Recommended tool is "sieve" form and sieve language to sort emails: GNU Mailutils https://mailutils.org/ In my particular example I am using the command line "sieve" to save mbox function save-maildir-by-to () { sieve -f /home/admin/Maildir/Sent.mbox.2021 "/home/data1/protected/Programming/System Administration/sieve/save-by-to.sieve" && echo Sieve DONE. } And /home/data1/protected/Programming/System Administration/sieve/save-by-to.sieve being following: require [ "fileinto", "variables" ]; if address :matches [ "to" ] "*" { set "recipient" :lower "${1}"; fileinto "~/Maildir/${recipient}"; } You may look into the sieve language and sort emails by other means. You also need to give the default maildir option to sieve. It can convert from one format to other. Thus you could sort it by date or anyhow. What I recommend is that every conversation with per...@example.com is saved in ~/Maldir/per...@example.com Then by single click on the email from per...@example.com I am launching new instance of mutt to review all previous emails related to this person. Isn't that handy? Then by clicking q, I exit the new instance of mutt and come back to original email. Then I have database backed CRM system, so if I wish to find any person, that person may have assigned multiple email addresses and I can then review them with single click or by choice within mutt. Mutt is then opening "mutt -f ~/Maildir/someem...@example.com" in new terminal, but it can work in console as well. To understand sieve language, look in the manual of GNU Mailutils. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: How to 'hook' different programs to view text/html?
* Chris Green [2022-01-18 20:45]: > I have the fairly standard setup for viewing HTML messages in mutt:- > > auto_view text/html > unalternative_order * > message-hook ~A "alternative_order text/html text/plain text" > > (The unalternative_order is because I have one special case where I > switch the order of text/html text/plain) > > ... and in ~/.mailcap:- > > text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html > > > > However I now have a requirement where I want to run HTML messages > from one particular mailing list (well, it's a forum actually, but I > get the messages by E-Mail) through a program other than lynx. > > Is there a straightforward way to do this? It's easy enough to use a > message hook to catch the messages from the site but what do I need to > do then to convert the messages and feed them into the pager? I am sure you can, instead of individual program, run a dmenu or other similar menu in console, maybe such as fzf, or console dialogs and then choose by which program to open the html files. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: pretty-print mutt emails
* Anders Damsgaard [2021-11-22 12:05]: > * Globe Trotter via Mutt-users [2021-11-22 00:47:10 > +]: > > > What is the recommended way to pretty-print mutt emails? I found a > > sourceforge perl script called muttprint but that was last updated in 2008, > > and I was wondering what folks here recommended? > > > > Thanks! > > Hi, > > I use the following sh(1) script to format the message as troff and > convert to pdf: https://adamsgaard.dk/tmp/muttprint-groff.sh > > It's a bit ugly in places, but it works for me. This is an example: > https://adamsgaard.dk/tmp/muttprint-example.pdf > > I bind it in my muttrc with the following: > > set print_command="$HOME/.config/mutt/muttprint-groff.sh" Very nice. I find it simple and good. I would like to have the header fields rather aligned to left side. When using grep, I think `grep -m1' should be used to find the first match, as I wonder what would be the result if words like "From:" or "Date: " are found in the body of the email, not only in the header. I also think I can convert your script to use Asciidoctor instead of groff, https://asciidoctor.org/ -- so I will work on it. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: pretty-print mutt emails
* Globe Trotter via Mutt-users [2021-11-22 03:48]: > What is the recommended way to pretty-print mutt > emails? I found a sourceforge perl script called > muttprint but that was last updated in 2008, and I was > wondering what folks here recommended? I use muttprint without problems. Find it attached, as maybe I have changed something in the script, you can make the diff. Then I have this settings in ~/.mutt/defaults which I load from ~/.mutt/muttrc set print_command="/home/data1/protected/bin/muttprint_print.sh" And the script `muttprint_print.sh' is attached as well. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/ #!/usr/bin/env perl # # Hinweis: Tabulatorbreite: 4 Zeichen # Notice: tab width: 4 characters # # # #Muttprint - pretty printing of mails with Mutt# #Copyright (c) 2000-04, Bernhard Walle # #Copyright (c) 2005,Lukas Ruf# # # #This program is free software; you can redistribute it and/or # #modify it under the terms of the GNU General Public License as# #published by the Free Software Foundation; either version 2 of# #the License, or (at your option) any later version. # # # #This program is distributed in the hope that it will be useful, # #but WITHOUT ANY WARRANTY; without even the implied warranty of# #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # #General Public License for more details. # # # #You should have received a copy of the GNU General Public License # #along with this program; if not, write to the Free Software # #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # # #You find the GPL in the file "COPYING" which was distributed # #with Muttprint. For a German translation look at # # # #http://www.suse.de/de/private/support/licenses/gpl.html # # # # Deklaration erzwingen use strict; use vars qw(%Config $texFontenc %String); use sigtrap qw(die INT QUIT TERM); use POSIX; use Text::Wrap; use File::Temp qw(tempdir); use utf8; # boolean type use constant TRUE => 1; use constant FALSE => 0; use constant COUNTRYCODE=> 0; use constant LANGUAGECODE => 1; use constant CHARSET=> 2; use constant CHARSET_TEX_NOTATION => 3; use constant BABEL_LANGUAGE => 4; use constant TEX_FONTENC=> 5; # BEGIN VARIABLES our $VERSION = "0.72d"; my $PACKAGE = "Muttprint"; Subroutinen mit Prototypes sub readConfig (@); sub readOpts (); sub getPaperConfig (); sub findCommonDir ($); sub createLatex (); sub getRealname ($); sub getShortFrom($$); sub getNumberOfPages ($); sub copyFile ($$); sub printDuplexNoCups (); sub printDuplexCups ($$$); sub modifyPS ($); sub createTemp (); sub setStrings (); sub writeFormated ($*$); sub decodeHeader(); sub getDefaultPrinterCDE(); sub changeForXface($); sub convertDate($); sub getISOlatinExtensions($); sub fatalError($); sub printWarning($); sub output (*@); sub outputstd (@); sub printLog($); sub input (*); sub native2utf ($); sub utf2native ($); sub getLocaleInformation($); sub convert_init (); 'private' variables for the rest %Config = ( PRINTER => '', PRINT_COMMAND => 'lpr -P$PRINTER', PENGUIN => 'on', DUPLEX => 'off', SPEED => '30', PAPERSAVE => 'off', FONT=> 'Latex', PAPER => 'A4', DEBUG => '0', REM_SIG => 'off', REM_QUOTE => 'off', WAIT=> '30', TOPMARGIN => '19', BOTTOMMARGIN=> '22', LEFTMARGIN => '20', RIGHTMARGIN => '20', HEADRULE=> 'off', FOOTRULE=> 'off', FRONTSTYLE
Re: how to add domain name to email address (that is different from hostname)
* Globe Trotter via Mutt-users [2021-10-16 03:18]: > Hi, > > I am wondering how it is possible automagically add a given domain name to an > email address that is not in my address book. > > Specifically, if I type joe and joe is in my addressbook (or is not a > complete email address) as my recipient, I get: > > joe@hostname > > what I want to happen is for joe to automagically expand to j...@yahoo.com > (say). You use "a" to add aliases, just try and you may figure it out. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: How to create local label and enlist/see them
* Bhaskar Chowdhury [2021-09-18 07:31]: > Well, I am trying to figure out ,how it could be done . As the subject line > said , I need to create specific label on certain message and later wanted to > view them in pager . Probably if I wish , selecting one of them and see those > specific label mails.(Not sure though is this something "l" or > "limiting" features does?) I use "Y" to edit label in Mutt, which is for a new header added and looks as following: X-Label: MY-LABEL Then if I do search like by using "/" I would enter: "~y MY-LABEL" to find the next message, or I could limit the view to "MY-LABEL" labeled messages by using "l" and "~y MY-LABEL", that is how you find those messages. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: using mutt with postfix and localhost:25
* Ofer Inbar [2021-09-13 16:17]: > On Mon, Sep 13, 2021 at 08:33:43AM +0300, > Jean Louis wrote: > > > * Ofer Inbar [2021-09-13 02:15]: > > > > All I do is: > > > > > > > > sudo ssh -L 25:mailhub:25 username@your_server > > > > > > > > And then, configuring 'localhost' as my smtp server on port 25 > > > > gets my mail sent directly forward through the SSH link. > > I just want to clarify that this is mis-attributed. > I did not write that, the OP of this thread did. > -- Cos Sure. I agree on that, it was not well quoted but also not 100% bad as the number of > symbols designates also some previous quotations. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: using mutt with postfix and localhost:25
* Ofer Inbar [2021-09-13 02:15]: > > All I do is: > > > > sudo ssh -L 25:mailhub:25 username@your_server > > > > And then, configuring 'localhost' as my smtp server on port 25 > > gets my mail sent directly forward through the SSH link. I have just tried the method and mutt somehow got the certificate from port 25, I had to accept it (once) and then it started authenticating. >From Mutt manual: Since all protocols supported by Mutt support/require authentication, login credentials may be specified in the URL. This has the advantage that multiple IMAP, POP3 or SMTP servers may be specified (which isn't possible using, for example, $imap_user). The username may contain the "@" symbol being used by many mail systems as part of the login name. The special characters "/" (%2F), ":" (%3A) and "%" (%25) have to be URL-encoded in usernames using the %-notation. How I see that case of forwarding port 25 which is normally not used with authentication on localhost, is that you should better forward the other port like 587 which is normally used WITH authentication, and then use that port to submit emails. As the manual says "since all protocols supported by Mutt support/require authentication" -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: using mutt with postfix and localhost:25
* Globe Trotter via Mutt-users [2021-09-12 17:47]: > Thank you for this. OK, so you are correct in that doing nothing > works on my office machine but not when I connect to it remotely to > deliver my mail using ssh -L etc and am using that server to deliver > my email. Good that you explained your method of the connection. And did you verify that you can reach localhost at port 25 with certainty? You can verify it by using `telnet': $ telnet localhost 25 and if there is banner then you have SMTP server forwarded to local host. Ports under 1024 can be forwarded only as `root' as they are considered privileged. If you cannot reach the port 25 on localhost try forwarding it to port 1025 and then dispatch to that port. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: displaying html links inside mutt
* Jean Louis [2021-09-10 09:56]: > > I can open the html in an external browser and there I find the > > link, but I would like an in-mutt solution (I don't really like > > going to the browser to read my email if I can help it). This is > > becoming quite a big concern for me. My solution is not really what you want like to open links in mutt directly but solution with `elinks' does stay in the console mode until you wish to open the link in external graphical browser. Another solution inside of virtual terminal is from: https://lukas.zapletalovi.com/2013/07/hidden-gems-of-xterm.html Open URL Best feature ever. I waited for years for this one. There is a new event called exec-formatted which allows you to execute arbitrary commands. If you make a PRIMARY selection before that, you can open URLs in browser easily. Do this: XTerm*translations: #override Shift : exec-formatted("xdg-open '%t'", PRIMARY) select-start() select-end() in ~/.Xdefaults and the XTerm solution may not be so functional. Also to mention is `urlscan': Description : Mutt and terminal url selector URL : https://github.com/firecat53/urlscan And then there are other terminal emulators that will recognize URL and underline it for you. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: displaying html links inside mutt
* Globe Trotter via Mutt-users [2021-09-10 07:30]: > Hello, > > I am still new to mutt (having moved from sylpheed) and finding my way. > Great, but one of the major issues that I have been having is that sometimes > I get some e-mail which is written in html but which has no indication of any > links, but has some links that are embedded/hidden. So, there are two things > I would like to say here. In the first case, I get an email and says, for > instance: "Edit here." But there is no indication that there is a link, much > less what the link is. So, in many cases, I am finding myself just not even > realizing these actions on emails (not in the above case, because it > specifically says that there is an action required on my part, but sometimes, > the text is ambiguous). I can open the html in an external browser and there > I find the link, but I would like an in-mutt solution (I don't really like > going to the browser to read my email if I can help it). This is becoming > quite a big concern for me. > > To be sure, there are some cases where I get the links displayed, > but this is not always, and I am trying to find out how to make it > such that it is displayed always. I know a solution that works well: 1) Make HTML attachments to be open with `elinks' browser; this is good enough to open links in console mode; but then follow to open up links with external browser; In ~/.mailcap I have following: text/html; elinks -force-html '%s'; 2) Go into setup in `elinks' with `o' to options, "Document" then "URI Passing" and then press `a' to add new option, you may name it like "External" press `e' on that option and enter your favorite browser, I have something like "iceweasel %c" -- which means if I wish to open the link with external browser, I would use option under menu "Link" -> "Pass link URI to external command"; 3) To make it respond quickly on the key, go to "Setup" -> "Keybinding manager" -> "Main mapping" -> "Pass link URI to external command" and press ENTER, choose your keybinding, I have ";" for example; 4) When you wish to view HTML attachment, then you press enter in attachment menu and `elinks' browser will open. You can read the HTML document and browse with `elinks' the Internet. If you wish to open the link in external browser, you press the key binding, in this example it was ";" -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Faster message body searching
* Chinmaya Nagpal [2021-08-20 23:20]: > Is there any way to make it faster to do ~b limits in maildir mailboxes? > I don't really use notmuch for much other than message body searching so > I'm considering if I should get rid of it entirely. If you don't know who is the correspondent and you wish to find message by body search then either you would use indexer like notmuch, and I am using "mu" indexer https://github.com/djcb/mu/ as I find it better; or maybe you could use simple `grep' to locate the message, which would be probably slower with larger number of Maildirs. In order to limit searches in bodies to specific conversant my Maildir setup is such that all emails related to specific email address are automatically saved to corresponding Maildir folder: ~/Maildir/u...@example.com is Maildir directory containing all emails to and from u...@example.com ~/Maildir/other-u...@other-example.com is Maildir directory containing all emails to and from other-u...@other-example.com That way if I wish to search with ~b narrowed and related to specific email address then the search goes much faster. Otherwise I have to use indexer to locate those messages which I do not know to which conversant they belong. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Retrieve inbox contents and email body
* Julius Hamilton [2021-07-07 22:57]: > Unfortunately, I have been trying to get going with some simple tools like > grepmail and mail and I can't find an answer to a simple question I > have. I recommend that you re-phrase the simple question. How I have understood, you wish to see if there are some emails on the remote IMAP server related to specific recipient or sender. Is it? -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Retrieve inbox contents and email body
* Jon LaBadie [2021-07-08 08:37]: > > Could anyone provide me with some simple steps to download my Gmail inbox > > to my filesystem as a mailbox, so that I could grepmail through it? I did > > read that the mailbox could be saved to var/mail or just $HOME. In either > > case I think grepmail can search for it and find it. > > Didn't know, I have google send my gmail to my home account. > > I expected you could just select the desired gmail messages and download > them. Found out you can only do single messages that way. > > Asking google how to do it got me to takeout.google.com. Google lets > you download all your data throught "takeout". Its a little clumsy, > but if you deselect all and reselect just "mail", you can download > all your gmail (trash, spam, and archive included :)). - Use Google IMAP server - Use `movemail' or `fetchmail' or `imapsync' to synchronize with computer -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Retrieve inbox contents and email body
* Julius Hamilton [2021-07-07 22:57]: > Could anyone provide me with some simple steps to download my Gmail inbox > to my filesystem as a mailbox, so that I could grepmail through it? I did > read that the mailbox could be saved to var/mail or just $HOME. In either > case I think grepmail can search for it and find it. I use the program `movemail' from GNU Mailutils package to download it offline. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Retrieve inbox contents and email body
* Julius Hamilton [2021-07-07 20:27]: > Thanks. > There is a lot of good stuff here to look into. > I think I will try with grepmail first. > I was wondering what the simplest way to send an email might be - the > mentioned "mail" unix utility, perhaps? Mutt is the way. Use whatever you have available. If you have sendmail, you can echo email message and use sendmail. You can connect to SMTP server and send email from command line by using raw connection commands. Description : Swiss Army Knife SMTP; Command line SMTP testing, including TLS and AUTH URL : https://jetmore.org/john/code/swaks/ I am using GNU Mailutils' program `mail' so often, and I send emails by using Emacs Lisp library and Common Lisp library for `mail': Emacs Lisp: rcd-mail.el package as bindings to GNU Mailutils "mail" program https://hyperscope.link/3/8/3/0/3/rcd-mail-el-GNU-Mailutils-mail-program.html I have tried using mutt as batch in the same manner, I could maybe rewrite it for mutt. Mutt does some things in batch mode better than `mail' maybe some features are missing. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: Retrieve inbox contents and email body
> The context is that I just would like to send emails and check for > responses in a more precise and quick way than opening my inbox. I would > like to have commands at my disposal when I am working on something to just > send an email directly and later check for responses to that email, or > check for all new emails from a particular sender. That info would need to > come back as the output of commands, to stdout. How I understand it is that you wish to automatically verify the existence at IMAP server of responses to particular email address. In almost every GNU/Linux distribution there shall be package with GNU Mailutils https://www.mailutils.org and inside there is one program named `from', that has among others the following option: -s, --sender=ADDRESS print only mail from addresses containing the supplied string What is interesting is that it will work not only with local mail but it can work with remote server. For help just write to bug-mailut...@gnu.org mailing list even without subscription. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Now about CRM functions - Re: How to intercept recipient before reply, and before sending?
* P. Mazart [2021-07-01 09:18]: > > This is all good as brainstorming. > > Nice, any chance that this system will be talked about in a blog or > something like that? This CRM of yours sounds like an interesting read. My business does depend on Mutt. Yesterday I was thinking how much we are locked to specific tools and habits as without them so much of the life could break down. On the other side, there is no quicker email client but Mutt. Few others similar clients simply don't perform efficient enough for my case. Major principle I am using is to designate a separate maildir folder for separat email address. If I am having conversation with j...@example.com all of the emails to and from this email address will be saved into ~/Maildir/j...@example.com Whoever implements this principle will gain tremendous advantages: == - I am pressing ESC-v to get all previous emails related to email address I am reading either in the pager or in the index: macro index,pager \ev ":set wait_key=noef > ~/tmp/ef-email!mutt-emailsof.lisp:set wait_key=yes" "Quickly view maildir for contact ID" whereby the script mutt-emailsof.lisp simple takes the email address from ~/tmp/ef-email extracted by program `ef' which I have previously sent attached. This script is just making few more checks, for example, email written as someb...@google.com may be looked in ~/Maildir/someb...@google.com but also in ~/Maildir/someb...@google.com so there could be some problems with upper cased letters. In general when saving emails I am using lower cased letters though it is not respecting the RFC. However, it works well for now. The script will thus open a new instance of Mutt that will read the recipient's Maildir folder (it could be mbox). My script also verifies OTHER email addresses of the same person, not only single email address. A single person may have previous emails, sometimes 5-7 different email addresses and maybe I wish to review conversation of the person, not just conversation of single email address. For people wishing to implement this system it will suffice to review single email address' conversation. I am sure that spawning multiple mutt instances one from each other is not so common. Maybe one could modify mutt, switch to folder, and remember the last folder to switch to last folder. But due to network connections that would cause just more delays. Thus I have mentioned here 2 principles for the users' workflow that can be very useful: 1. Detect the recipient's email address -- that is done by program `ef' or other grep. I would prefer if it would be directly provided by Mutt in format like $to-email $form-email, etc. Then I would not need to use external tools. It would allow direct invokation of programs related to that specific recipient. 2. Invokation of external program related to the recipient's email address is allowing plethora of extensions: - Spawning mutt from within mutt on the related email address is great extension to review all the previous conversations related to recipient. It works easy because of ~/Maildir/j...@example.com setup of Maildir for each specific email address. This again enables easy searching of emails without external indexer as long as email address is known. - Not only that, because email address has been extracted or can be known, now it is so easy to make a macro or key in Mutt to invoke various other CRM related functions: Add note related to recipient, add follow up, subscribe the recipient into specific mailing list (I mean those used in sales and marketing), verify which mailing lists is recipient subscribed to, unsubscribe it as some people send unsubscribe requests by email, verify which people have been recommended by that person, open up directory that is related to that person, review files or view images of a girl you are considering for dating among other 246 girls (as example). People send contracts, invoices, files, I am storing everythin by recipient without knowing where as that goes automatic. Thus quickly opening the right directory related to recipient is important function. Now I am thinking I should implement the same principle to saving of attachments, before the attachment is saved I would obtain the email address and then change on the fly the directory where attachments are saved. Plain fiels are saved on my side to directories like: /home/data1/protected/hyperscope/3/5/5/8/2/By-ID/1/files/2020/05/2020-05-14 The above directory I am never accessing manually by browsing. I am just looking for the person and click `f' to access all files pertaining to the person. New files are normally sorted by year/month/date principle. Same principle can be implemented when saving attachments from Mutt so that I don't know to invoke additional "sto
Re: How to intercept recipient before reply, and before sending?
Dear P. Mazart, Thanks, I think I have solved the first part of my need, though it is not any more the same as what I was doing before. Here is the macro: macro index,pager r "ef > ~/tmp/ef-email" program `ef' is compiled with GNU Mailutils libraries, but it could be probably a specialized `grep' command to capture the recipient's email address. This command did not fail me yet. Recipient is the one in the From: field, thus `ef' implies "Email from". It is small program made by Sergey, the maintainer of GNU Mailutils https://www.mailutils.org and I am attaching the program in this message. I am using it reliably for years. It is nothing special, it just extracts email address from the From: field. There is also `et.c' file attached which I have slightly modified that it captures the To: recipient. When replying on email the From: the program will simple save the current email address in the file ~/tmp/ef/email -- and then when editing I have got the reference for automatic further hyperlinking. When I say "hyperlinking" I don't mean HTML or similar. I mean functions which allow me to quickly switch to information pertaining to the recipient, let us say the phone number if I wish to call recipeint during email writing, or maybe I wish to see which other previous emails did same recipient receive, SMS list or notes related to recipient. This works well in Emacs as it is programming language. * P. Mazart [2021-06-30 10:01]: > I think you could always create a {python,bash,ruby} script or c-program > and let it “mimic” an editor when you reply: > > :macro index r "set > editor=\"edit-id-then-reply.py\"set > editor=\"vim\"" Now I found simpler solution, instead of injecting it in the body of email, I am saving the current recipient's email address in the outside file. This may not work well in my case as I am also using background editing. So that could be solved if I would have some reference to hook on it. That could be the file name, but I do not know how is temporary file name generated or if I can change the name of it. Let us say if I could change the name of temporary file, then I could have a reference to hook (not in mutt's context) the email address to the temporary file generated. That would solve the problem with background editing. In any case, I can put some attention not to make a mistake. Another solution could be searching for the email address in the buffer as a reference. Anyway I have to be able to invoke personal relationship management options on the email address. > > Is there a way to intercept the recipient's address, like making a > > macro for the `y' key binding? > > Similar to the above, you could create a sendmail-compatible wrapper, > that does the interception and later actually runs sendmail or msmtp or > else. I was looking in my current setup and I was counting generally when emails were sent but not to which person they were sent. Following macro was and is still recording the inaccurate time when email has been sent from Mutt: macro compose y ":set wait_key=no!general-log.lisp 'mutt: message sent'" Instead of that I will then soon implement very similar piping as in the previous macro, so that program `general-log.lisp' can get the recipient's email address in real time from the message, extract it and use it to record that email has been sent to person at specific time. That again also solves the problem with background editing as then specific recipients are captured before sending the email and will not collide with other background edited emails. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/ #include int main (int argc, char **argv) { int rc; mu_message_t msg; mu_header_t hdr; struct mu_address hint; mu_address_t addr; char *val; char const *email; mu_stdstream_setup (MU_STDSTREAM_RESET_NONE); MU_ASSERT (mu_stdio_stream_create (&mu_strin, MU_STDIN_FD, MU_STREAM_READ|MU_STREAM_SEEK)); mu_set_program_name (argv[0]); mu_registrar_record (mu_mbox_record); MU_ASSERT (mu_stream_to_message (mu_strin, &msg)); MU_ASSERT (mu_message_get_header (msg, &hdr)); rc = mu_header_aget_value_unfold (hdr, MU_HEADER_FROM, &val); if (rc == MU_ERR_NOENT) return 1; memset (&hint, 0, sizeof hint); rc = mu_address_create_hint (&addr, val, &hint, MU_ADDR_HINT_DOMAIN); if (rc) { mu_error ("can't parse address %s: %s", val, mu_strerror (rc)); return 1; } MU_ASSERT (mu_address_sget_email (addr, 1, &email)); mu_printf ("%s\n", email); return 0; } # Extracts the email from CPPFLAGS=`mailutils cflags` LIBS=`mailutils ldflags mbox` ef: ef.c cc $(CPPFLAGS) $(CFLAGS) -oef ef.c $(LDFLAGS) $(LIBS) #include int main (int argc, char **argv) { int rc; mu_message_t msg; mu_header_t hdr; struct mu_address hint; mu_address_t addr; char *val; char const
Re: Is there any programmatic way of changing message recipients (specifically To:)?
* Chris Green [2021-07-01 11:04]: > The subject says it all really. :-) > > Is there any way that mutt can change the To: header of a message? > This could be either on its way to 'compose' or on its way out from > 'compose'. > > Basically I want to automate changing To: when replying to certain > messages where To: (and probably some other headers) match a > particular expression. And do you have just single replacemnt or multiple replacements based on the recipient's email? On my side, not that I need to replace recipient, but I do have need to track email sending and I have for each recipient different parameters. That is why I ask. You would do it with macro just like previously explained for my need case. It is similar, you need to enable editing and then have script to replace it on the fly. When I make my own, I can show how it works. Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
Re: How to intercept recipient before reply, and before sending?
* P. Mazart [2021-06-30 10:01]: > Hi Jean, > > we missed each other in IRC, so here’s my reply. Thanks. > I think you could always create a {python,bash,ruby} script or c-program > and let it “mimic” an editor when you reply: > > :macro index r "set > editor=\"edit-id-then-reply.py\"set > editor=\"vim\"" > Once you hit your reply button »r« the editor is changed, started and > set back again. It could also start your favourite text editor. > > e.g. you could use this as »edit-id-then-reply.py«: > > #!/usr/bin/env python3 > > import sys > import subprocess > > with open(sys.argv[1], 'a') as email_file: > email_file.write('Hello, I am your ID\n'); > > subprocess.run(['vim', sys.argv[1]]); > > This would open the filename of the reply-email, then read it and change > some of its content (e.g. insert user id), then start your text editor so > you can type your reply. That is good idea. It is nice hack. Intercept the file, change it a bit if necessary and delegate to editor. I think in this version I will not get the To: field, I will get the reply message. What I need is recipient's email to associate it with the ID from the database. I could maybe pipe it, get the Email, associate with ID, store it somewhere, then launch editor that is anyway Emacs that could by the file name recognize that it has to insert ID if not inserted. Maybe first piping, getting email address, recording ID, then reply as usual. The ID actually need not be in the text, it can be outside of Mutt, important is that I can access the "current ID" from editor. This is all good as brainstorming. > > Is there a way to intercept the recipient's address, like making a > > macro for the `y' key binding? > > Similar to the above, you could create a sendmail-compatible wrapper, > that does the interception and later actually runs sendmail or msmtp or > else. Also good idea. That is what I have to do. Thanks. Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/
How to intercept recipient before reply, and before sending?
I would like to intercept the recipient before the reply or reply to group, and before sending and I am asking for best approach. Explanation: Every user at my side has unique ID number. When replying to recipient I am editing a text related to recipient. Within Emacs editor I have a CRM system that jumps to various people ID numbers. Thus I would like to inject the ID number into the text before the reply. That is very useful as I could then use single press to get all other recipient's information (phone, notes, other emails, etc.) straight from the text I am replying to that recipient. Is there a way to inject anything into the quoted message by for example filtering the message, injecting the ID if it does not exist, and then passing it again back to Mutt? Another question is related to recording the fact that I have sent email to specific user at specific time. This is very useful for the CRM system. That would mean that before pressing `y' to send final email I would need to intercept the recipient's email address. Is there a way to intercept the recipient's address, like making a macro for the `y' key binding? Thanks in advance, Jean
[tip]: Recording people before mailto: link
This tip may be useful for people who are using Mutt in connection with any kind of database like CRM Customer Relationship Management systems. I have made a mutt.desktop file in ~/.local/share/applications/mutt.desktop where I am designating a script which is intercepting mailto: links that I usually click on the website to contact people: [Desktop Entry] Version=1.0 Type=Application Name=RCD Mutt GenericName=Email Client Comment=Mutt Exec=/home/data1/protected/bin/rcd/rcd-mutt %U Icon=mutt Terminal=true MimeType=x-scheme-handler/mailto; StartupNotify=false Categories=Application; The script `rcd-mutt' basically parses the email address and asks the user (me) about the group of people where I wish to sort that new email address. It is recording the new email address into the database before writing to it. Thus it creates relation to database objects. If email already exists in the database, it just continues with Mutt. As script is pretty customized for myself it will not give any useful insight, but users can make such script in shell or any other programming language. Purpose of this explanation is to help users intercept the email address and record it in a global address book before writing to it. #!/usr/bin/env -S clisp -norc (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/configure-system.lisp") (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/connect.lisp") (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/dbtools.lisp") (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/crmtools.lisp") (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/utilities.lisp") (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/shelltools.lisp") (when *args* (let* ((email (string-trim '(#\Space #\Newline #\Tab) (car *args*))) (email (replace-all email "mailto:"; "")) (question-mark (search "?" email)) (email (if question-mark (substring email 0 question-mark) email))) (when email (let ((id (rcd-crm-id-by-email email))) (if id (shell (format nil "mutt ~A" (car *args*))) (let ((account (shell-1st-result "rcd-sql-select.sh account"))) (if account (let ((email (sql-escape-string email))) (rcd-sql (format nil "INSERT INTO people (people_lastname, people_account1, people_email1) VALUES (~A, ~A, ~A)" email account email)) (shell (format nil "mutt ~A" (car *args* (shell (format nil "yad --center --text \"Could not find account for email ~R. ABORTING.\"" email) Jean