Re: Retrieve inbox contents and email body
On 06Jul2021 18:19, Julius Hamilton wrote: >Thanks very much. >I am now looking into using a Python IMAP library. Note that imaplib from the Python standard library is only a low level wrapper for the protocol, not a fulling fledged "remote IMAP mailbox" tool (which you might expect to trweat it like a map or something). There are other IMAP modules in PyPI offering higher level access. >However, I think there must be a way to just dump the contents of a Mutt >page, and that could be an easier short-term solution. >You mentioned there being a print function. See the manual for "print", "print_command", "print_decode". The defaults are ok, except that you would want to set "print_command" to something like "cat" for the message to appear on stdout. A bit of experimentation reveals that is as good as , so something like this: mutt -e 'set wait_key=no; push ".cat"' -f YOUR_MBOX seems to work. Open mailbox, tag every message (or whatever subset you want), pipe through "cat", quit. This is all a bit of a hack - mutt is inherently an interactive programme and the above works my pushing keystrokes onto the input stream. Cheers, Cameron Simpson
Re: Retrieve inbox contents and email body
On Tue, Jul 06, 2021 at 06:19:54PM +0200, Julius Hamilton wrote: Thanks very much. I am now looking into using a Python IMAP library. However, I think there must be a way to just dump the contents of a Mutt page, and that could be an easier short-term solution. You mentioned there being a print function. Could you provide an example of using that to print the inbox to stdout? It would have to be automatic, i.e. not requiring the user to actually open Mutt themselves and type the print command. So that leads me to the question of if this command can somehow be passed to mutt as a command line option, or if there is some bash automation tool for calling it inside Mutt anyway. 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. Thanks very much, Julius If looking at separate programs, what about "grepmail"? Ex.grepmail -h -B -e '^Subject: ' -h (grep only headers) -B (print body with limited headers) jon -- Jon H. LaBadie j...@labadie.us 11226 South Shore Rd. (703) 787-0688 (H) Reston, VA 20190 (703) 935-6720 (C)
Re: Retrieve inbox contents and email body
Thanks very much. I am now looking into using a Python IMAP library. However, I think there must be a way to just dump the contents of a Mutt page, and that could be an easier short-term solution. You mentioned there being a print function. Could you provide an example of using that to print the inbox to stdout? It would have to be automatic, i.e. not requiring the user to actually open Mutt themselves and type the print command. So that leads me to the question of if this command can somehow be passed to mutt as a command line option, or if there is some bash automation tool for calling it inside Mutt anyway. 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. Thanks very much, Julius On Tue, Jul 6, 2021, 00:44 Cameron Simpson wrote: > On 05Jul2021 19:19, Julius Hamilton wrote: > >I would like to retrieve the contents of my inbox - the emails' > >metadata, > >sender, subject, date - to stdout, rather than by opening an application. > >Can Mutt dump the inbox page? Does it have any way to return to stdout > >information about the inbox? Or should I use a different tool for this? > > I would use a different tool. Personally I'd write a little Python > programme to read you inbox (IMAP? Local mail folder?) and report. > > >I would also like to retrieve the body of a specific email in the same > way, > >to stdout. Do the emails have identifier tags by which they can be > >specified? Or, what would be a way to do this? > > All messages have a Message-ID: header which has a unique value per > message. Mutt's %i pattern operator matches message-ids. I suppose you > could invoke mutt from the command line this instructions to open the > message based on the message-id and "print" it, specifying the print > action as something which writes output. > > But again, if I'd already written the Python programme above (summarise > ths inbox) it would probably be easier to extend that to write out the > desired message. > > More context? There are probably already tools to do things like what > you suggest, even if they are not exact matches for what you ask for. > > Cheers, > Cameron Simpson >