pfr

Is it possible to use /usr/bin or an already existing directory so to keep the filesystem as clean as possible?

Sure: there's no program called hmail, so you can drop it into /usr/bin, but, you should be aware that that's what /usr/local/bin is traditionally for: user created or installed, scripts and programs (which is also why it's already in the PATH). You might, in due course, write/install more binaries for your user and/or yourself. Cleaner, actually, I feel to put these into their own directory, rather than mixing it in with the system stuff.

In fact, I like NetBSD's /usr/pkg/bin and /usr/local/bin split better than FreeBSD's all-extras-in-/usr/local/bin scheme. There, I have to put my locally-written code into /opt/, or some-such, if I want to keep things separate.

Another thing I just discovered, and happen to like now in NetBSD, is this: both the mailx(1) and Heirloom mailx(1) man-pages on both BSDs reference the Mail Reference Manual, but, (for a system which claims to have comprehensive documentation,) FreeBSD doesn't have it. Anywhere. (I looked for it because I vaguely recall reading it on FreeBSD back when it was at version 2.2. They must've removed it in the interim.)

NetBSD still has it. It won't cover IMAP/POP3/SSL, etc, but it is a tutorial reference rather than simply a man-page. You can read in here on your local system (if you installed the misc distribution set):

/usr/share/doc/reference/ref1/mail/

a year later

It's been some time, and I am still using heirloom-mailx believe it or not. I've become fairly comfortable with the keybindings etc. but there is just one thing that I cannot figure out. That is, to begin reading messages from the top i.e. most recent.

Currently, when I open my mail with $ hmail myemail@gmail.com It lists mail in my inbox from the oldest first, requiring me to scroll multiple pages to get to the most recent mail. Ideally I'd like to set something in the config to reverse this but I'd also be happy with a keybinding to catapult me to the top of my emails without needing to page though several times.

I've looked a the man page but i couldn't identify if this was possible. Any ideas @rvp ?

  • rvp replied to this.
  • oui likes this.

    pfr to begin reading messages from the top i.e. most recent.

    In ~/.nailrc, add set showlast

    pfr I'd also be happy with a keybinding to catapult me to the top of my emails

    At the & prompt h$

      pfr That didn't seem to work

      It's a global setting, so pull it out of any account definitions. (Worked on FreeBSD's heirloom-mailx-12.4)

      • pfr replied to this.

        rvp It's a global setting, so pull it out of any account definitions. (Worked on FreeBSD's heirloom-mailx-12.4)

        This is my .nailrc

        I've got it just under the account settings

        # This is the configuration file for Heirloom mailx (formerly
        # known under the name "nail".
        # See mailx(1) for further options.
        # This file is not overwritten when 'make install' is run in
        # the mailx build process again.
        
        # Sccsid @(#)nail.rc	2.11 (gritter) 8/2/08
        
        # Account datails
        account gmail {                                                                                            
                set ssl-verify=ignore
                set folder=imaps://my.email.address@imap.gmail.com
                set imap-auth=login
                set password-my.email.address@imap.gmail.com="**************************"
        
                set from="my.email.address@gmail.com (My Name)"
                set smtp=smtps://smtp.gmail.com:465
                set smtp-auth=login
                set smtp-auth-user=my.email.address@gmail.com
                set smtp-auth-password="****************************"
        }
        
        # Show most recent emails first
        set showlast
        
        # Do not forward to mbox by default since this is likely to be
        # irritating for most users today.
        set hold
        
        # Append rather than prepend when writing to mbox automatically.
        # This has no effect unless 'hold' is unset again.
        set append
        
        # Ask for a message subject.
        set ask
        
        # Assume a CRT-like terminal and invoke a pager.
        set crt
        
        # Messages may be terminated by a dot.
        set dot
        
        # Do not remove empty mail folders in the spool directory.
        # This may be relevant for privacy since other users could
        # otherwise create them with different permissions.
        set keep
        
        # Do not remove empty private mail folders.
        set emptybox
        
        # Quote the original message in replies by "> " as usual on the Internet.
        set indentprefix="> "
        
        # Automatically quote the text of the message that is responded to.
        set quote
        
        # Outgoing messages are sent in ISO-8859-1 if all their characters are
        # representable in it, otherwise in UTF-8.
        set sendcharsets=iso-8859-1,utf-8
        
        # Display sender's real names in header summaries.
        set showname
        
        # Display the recipients of messages sent by the user himself in
        # header summaries.
        set showto
        
        # Automatically check for new messages at each prompt, but avoid polling
        # of IMAP servers or maildir folders.
        set newmail=nopoll
        
        # If threaded mode is activated, automatically collapse thread.
        set autocollapse
        
        # Mark messages that have been answered.
        set markanswered
        
        # Hide some header fields which are uninteresting for most human readers.
        ignore received in-reply-to message-id references
        ignore mime-version content-transfer-encoding
        
        # Be xBSD compliant
        set bsdcompat
        
        # Only include selected header fields when forwarding messages.
        fwdretain subject date from to

        Version check

        $ pkg_info heirloom-mailx
        Information for heirloom-mailx-12.5nb2:
        • rvp replied to this.

          pfr I've got it just under the account settings

          I've got that order reversed in my .nailrc: global settings first, then the account stuff. Try it that way (heirloom mailx behaviour is a bit dodgy sometimes--showlast, for instance, doesn't seem to work if I set it at the & prompt).

          Otherwise, try s-nail, the heirloom-mailx replacement.

          • pfr replied to this.
          • pfr likes this.

            pfr I moved all of my account details to the end of the .nailrc file but this made no difference.

            Just tried out the NetBSD version, and... it works as advertised:

            Without set showlast:

            $ hmail -A yahoo -f '+Xxxx'
            host certificate does not match "localhost"
            Heirloom Mail version 12.5 6/20/10.  Type ? for help.
            "imaps://xxxxxx_x_xxxxxx@localhost:9997/Xxxx": 50 messages
            >   1 To xxxxxxxxxx@xxxxx.  Thu Dec 27 00:53    /2135  "xXxxxx-x.x.xx.x xxxxx()"
                2 To Xxx Xxxxxxx        Thu Dec 27 21:03    /2862  "Re: [Xxxxxxxxxx] xXxxxx"
                3 To Xxx Xxxxxxx        Fri Dec 28 04:52    /2137  "Re: [Xxxxxxxxxx] xXxxxx"
                4 To Xxxxx.Xxxx@xxxxxx  Tue Oct  1 11:42    /141474 "XXX Xxxxxxxxxx Xxxxxxx"
                5 To xxx@xxxxxx.xxx.xx  Sat Feb  8 05:06    /6522  "xxxxxxxxx-xxxxxxxx xxxx"
            [...]
            & q
            $

            With set showlast:

            $ hmail -A yahoo -f '+Xxxx'
            host certificate does not match "localhost"
            Heirloom Mail version 12.5 6/20/10.  Type ? for help.
            "imaps://xxxxxx_x_xxxxxx@localhost:9997/Xxxx": 50 messages
            [...]
               46 To xxxxxx@xxxxxxxxx-  Thu Aug 27 06:07    /1232  "Re: xxxxx-xxx: Xxxxxxx."
               47 To xxxxx-xxxx@XxxXXX  Sat Oct 10 20:31    /601   "Re: xxx/xxxxx"
               48 To xxxxx-xxxx@xxxxxx  Sat Oct 31 04:12    /849   "Re: xxx/xxxxx: xxx(1): "
               49 To Xxxxxx X. Xxxxxx   Mon Mar 22 22:27    /2347  "xxxxxxx-x.x-xxxxxxxx: x"
            >  50 To Xxxxxx X. Xxxxxx   Sun Apr 18 02:27    /4511  "xxxxxxx-x.x-xxxxxxxx: x"
            & q
            $

            set showlast inside an account block works too. My .nailrc is just the standard /usr/pkg/share/examples/mailx/nail.rc with my account stuff tacked on at the end. Find out what you're doing differently.

            pfr If I was to try s-nail is my .nailrc transferable over to .mailrc

            No idea.

            or s-nail.rc?

            No idea, and,

            pfr Any quirks to be aware of when switching over?

            also, no idea.

            I merely found out that a cmd.-line-based e-mail client like s-nail existed when I looked into this last year, but, I haven't used it at all sinceheirloom-mailx does the job for me.

              pfr

              1. Does setting showlast on the command line work?
                hmail -S showlast -A account ...

              2. If it does, try the updated hmail script in post #16.

              • pfr replied to this.
              • pfr likes this.

                rvp Does setting showlast on the command line work?
                hmail -S showlast -A account ...

                Nope. even that doesn't work...

                My hmail script only has a single line in it

                $ cat /usr/local/bin/hmail
                #!/bin/sh
                exec /usr/pkg/bin/mailx ${1:+"$@"}
                $
                • rvp replied to this.

                  pfr even that doesn't work...

                  1. Post the exact command-line that you normally use with hmail

                  2. Can you set that boolean on the command-line, then at the & prompt (after checking your mail as usual), do a set and check if showlast is set?

                  • pfr replied to this.
                  • pfr likes this.

                    rvp

                    1. $ hmail -S showlast -A gmail
                    2. See below (i've deleted the passwords and email adress etc)
                      & set
                      append
                      ask
                      autocollapse
                      bsdcompat
                      crt
                      dot
                      emptybox
                      folder  imaps://
                      from    
                      header
                      hold
                      imap-auth       login
                      indentprefix    >
                      interactive
                      keep
                      markanswered
                      newmail nopoll
                      password-
                      quote
                      save
                      sendcharsets    iso-8859-1,utf-8
                      showlast
                      showname
                      showto
                      smtp    smtps://smtp.gmail.com:465
                      smtp-auth       login
                      smtp-auth-password      
                      smtp-auth-user  
                      ssl-verify      ignore
                      ttycharset      UTF-8
                      &

                    So it appears to be set but is still shows me my oldest emails first

                    • rvp replied to this.

                      pfr So it appears to be set but is still shows me my oldest emails first

                      Bizarre...

                      1. Can you try the updated script in post #16?
                      2. Try a different folder on Gmail instead of inbox. Just supply a folder name with -f +folder_name. (Wondering if it's a problem with Gmail+Inbox. My inbox folders are usually empty as I move mails out after I've read 'em.)
                      3. Wondering also if we're blind men with elephants: ie. we've got the same creature, but looking at different bits of it and getting confused as a result:
                        List the email as usual (with & w/o -S showlast); copy the output into 2 files; run the auto-redacter (below) on each; post output.
                        #!/usr/bin/awk -f
                        # hide_mail.awk: redact stuff from a mailx(1) list (h) output.
                        BEGIN {
                        	FS = ""
                        }
                        NR <= 2 { print }
                        NR > 2 {
                        	for (i = 1; i <= 80; i++) {
                        		if ((i >= 7 && i <= 27) || i >= 56) {
                        			if ($i ~ /[[:upper:]]/)
                        				printf("X");
                        			else if ($i ~ /[[:lower:]]|[[:digit:]]/)
                        				printf("x");
                        			else
                        				printf("%c", $i "");
                        		} else 
                        			printf("%c", $i "");
                        	}
                        	printf("\n");
                        }
                      • pfr replied to this.

                        rvp

                        1. Already have 🙂
                        2. Still shows the oldest emails, even in a different folder.
                        3. See below:

                        Without -S showlast

                        $ ./auto-redacter.sh without.txt
                        $ hmail -A gmail
                        Heirloom Mail version 12.5 6/20/10.  Type ? for help.
                        "imaps://xxxxx.xxxxxxx.xxxxffer@imap.gmail.com/INBOX": xxxx xxxxxxxx
                          951 Xxxxxxxxx Xxxx        Sat Dec  1 09:02    /28957 "Xxxx xxxxxxxx xxxx XX "
                          952 XX XXXXXXXXXXX XXX X  Sat Dec  1 11:13    /203781 "Xxxxxxx xxx xxxx XX X"
                          953 Xxxxx                 Sat Dec  1 18:13    /17933 "Xxxx Xxxxx Xxxxx Xxxxx"
                         A954 Xxxxx Xxxxxxx         Sat Dec  1 20:20    /9804  "Xx: Xxxxxxxx."
                          955 xxxxx-xxxxxxx@xxxxxx  Sat Dec  1 21:38    /8755  "Xxxx Xxxxxx Xxxxxxx Xx"
                         A956 xxxxx xxxxxxxx        Sun Dec  2 20:08    /124971xx "Xx: Xxxxx xxxxx xxx"
                          957 Xxxxxxx Xxxxxxx       Mon Dec  3 11:35    /52996 "XX: Xxxxx xxxxx xxxxxx"
                         A958 Xxxxxxx Xxxxxxx       Mon Dec  3 15:28    /58359 "XX: Xxxxx xxxxx xxxxxx"
                          959 xxxxx                 Mon Dec  3 15:30    /6878  "Xx xxxxxxxxx xxxxx xxx"
                         A960 xxxxx xxxxxxxx        Mon Dec  3 16:06    /25792 "Xx: Xxxxx xxxxx xxxxxx"
                          961 Xxxxx Xxxxxxxx        Mon Dec  3 18:14    /23722 "Xxxxxxxxx xxxxx: xx Xx"
                         A962 Xxxxx Xxxxxxxxxxx     Tue Dec  4 13:59    /509719 "Xxxxxx xx Xxxxxxx xxx"
                         A963 Xxxxx Xxxxxxxxxxx     Tue Dec  4 17:00    /73054 "XX: Xxxxxx xx Xxxxxxx "
                          964 Xxxxx                 Tue Dec  4 17:08    /18443 "Xxxxx xxxx Xxxxx xxxxx"
                         A965 xxxxx xxxxxxxx        Tue Dec  4 19:25    /28957 "Xx: Xxxxx xxxxx xxxxxx"
                          966 Xxxxxx Xxxxxx Xxxxxx  Wed Dec  5 14:05    /350256 "Xxxx Xxxxxx Xxxxxx xX"
                          967 Xxxxxxx Xxxxxxx       Wed Dec  5 16:39    /95370 "XX: Xxxxx xxxxx xxxxxx"
                          968 xxxxxxxxx@xxxxx.xxx.  Wed Dec  5 18:23    /313660 "Xxxx Xxxxx xxxx xxx x"
                          969 Xxxxx Xxxxxxxxxxx     Thu Dec  6 10:36    /93603 "XX: Xxxxxx xx Xxxxxxx "
                        >F970 Xxxxx Xxxxxxxxxxx     Fri Dec  7 10:05    /130384 "Xxxxxxxx Xxxxxxxx"
                          971 Xxxxxxxxx Xxxxxx Xxx  Fri Dec 14 18:18    /305355x "Xxx Xxxxx Xxxxxxxx"
                          972 Xx Xxxxx Xxxxxxxx     Mon Dec 17 14:31    /735140x "Xxx"
                          973 Xxxxx Xxxxxxxx        Mon Dec 17 16:44    /67735 "XX: xx Xxxxx Xx Xxxxxx"
                          974 Xxxxx Xxxxxx Xxxxx X  Tue Dec 18 06:39    /496007 "Xxxx Xxxxx Xxxxxx Xxx"
                          975 Xxxxxx Xxxxxx         Tue Dec 18 23:11    /346492 "Xxxx xxxxx Xxxxxx xxx"
                         A976 Xxxxx Xxxxxxxx        Wed Dec 19 10:54    /78214 "XX: xx Xxxxx Xx Xxxxxx"
                          977 Xxxxxx Xxxxxx Xxxxxx  Thu Dec 20 13:31    /291878 "Xxxx Xxxxxx Xxxxxx xX"
                          978 XXXX                  Thu Dec 20 16:29    /276557 "Xxxxxxxx Xxxxxxx (Xxx"
                         A979 XX XXXXXXXXXXX        Fri Dec 21 17:07    /55847 "Xx: XX Xxxxxxxxxxx Xxx"
                          980 xxxxxxxxxxxxxxxx_xxx  Sun Dec 23 10:56    /690275 "Xxxx xxx Xxxxxxx xxxx"
                          981 Xxxxx Xxxxxxx         Mon Dec 24 20:01    /4857  "Xxx xxxxxx xxxxxx"
                          982 Xxxxxx Xxxxxx Xxxxxx  Wed Dec 26 07:10    /572548 "Xxxx Xxxxxx Xxxxxx Xx"
                          983 Xxxxx Xxxxxxxx        Fri Dec 28 13:09    /23730 "Xxxxxxxxx xxxxx: xx Xx"
                          984 xxxxxxx@xxxxxx.xxx.x  Tue Jan  1 11:05    /55771 "Xxxxxxx xxx xxxx Xxxxx"
                         A985 Xxxxxxxxx Xxxxx       Wed Jan  2 18:35    /158255 "XX"
                          986 Xxxxxxxxx             Fri Jan  4 10:48    /11352 "Xxxx Xxxxxxxxx Xxxx"
                          987 xxxxxxx@xxxxxx.xxx.x  Sat Jan  5 11:04    /56865 "Xxxxxxx xxx xxxx Xxxxx"
                          988 xxxxxxxxx@xxxxx.xxx.  Mon Jan  7 17:41    /313675 "Xxxx Xxxxx xxxx xxx x"
                        &
                        $

                        With -S showlast

                        $ ./auto-redacter.sh with.txt
                        $ hmail -S showlast -A gmail
                        Heirloom Mail version 12.5 6/20/10.  Type ? for help.
                        "imaps://xxxxx.xxxxxxx.xxxxffer@imap.gmail.com/INBOX": xxxx xxxxxxxx
                          951 Xxxxxxxxx Xxxx        Sat Dec  1 09:02    /28957 "Xxxx xxxxxxxx xxxx XX "
                          952 XX XXXXXXXXXXX XXX X  Sat Dec  1 11:13    /203781 "Xxxxxxx xxx xxxx XX X"
                          953 Xxxxx                 Sat Dec  1 18:13    /17933 "Xxxx Xxxxx Xxxxx Xxxxx"
                         A954 Xxxxx Xxxxxxx         Sat Dec  1 20:20    /9804  "Xx: Xxxxxxxx."
                          955 xxxxx-xxxxxxx@xxxxxx  Sat Dec  1 21:38    /8755  "Xxxx Xxxxxx Xxxxxxx Xx"
                         A956 xxxxx xxxxxxxx        Sun Dec  2 20:08    /124971xx "Xx: Xxxxx xxxxx xxx"
                          957 Xxxxxxx Xxxxxxx       Mon Dec  3 11:35    /52996 "XX: Xxxxx xxxxx xxxxxx"
                         A958 Xxxxxxx Xxxxxxx       Mon Dec  3 15:28    /58359 "XX: Xxxxx xxxxx xxxxxx"
                          959 xxxxx                 Mon Dec  3 15:30    /6878  "Xx xxxxxxxxx xxxxx xxx"
                         A960 xxxxx xxxxxxxx        Mon Dec  3 16:06    /25792 "Xx: Xxxxx xxxxx xxxxxx"
                          961 Xxxxx Xxxxxxxx        Mon Dec  3 18:14    /23722 "Xxxxxxxxx xxxxx: xx Xx"
                         A962 Xxxxx Xxxxxxxxxxx     Tue Dec  4 13:59    /509719 "Xxxxxx xx Xxxxxxx xxx"
                         A963 Xxxxx Xxxxxxxxxxx     Tue Dec  4 17:00    /73054 "XX: Xxxxxx xx Xxxxxxx "
                          964 Xxxxx                 Tue Dec  4 17:08    /18443 "Xxxxx xxxx Xxxxx xxxxx"
                         A965 xxxxx xxxxxxxx        Tue Dec  4 19:25    /28957 "Xx: Xxxxx xxxxx xxxxxx"
                          966 Xxxxxx Xxxxxx Xxxxxx  Wed Dec  5 14:05    /350256 "Xxxx Xxxxxx Xxxxxx xX"
                          967 Xxxxxxx Xxxxxxx       Wed Dec  5 16:39    /95370 "XX: Xxxxx xxxxx xxxxxx"
                          968 xxxxxxxxx@xxxxx.xxx.  Wed Dec  5 18:23    /313660 "Xxxx Xxxxx xxxx xxx x"
                          969 Xxxxx Xxxxxxxxxxx     Thu Dec  6 10:36    /93603 "XX: Xxxxxx xx Xxxxxxx "
                        >F970 Xxxxx Xxxxxxxxxxx     Fri Dec  7 10:05    /130384 "Xxxxxxxx Xxxxxxxx"
                          971 Xxxxxxxxx Xxxxxx Xxx  Fri Dec 14 18:18    /305355x "Xxx Xxxxx Xxxxxxxx"
                          972 Xx Xxxxx Xxxxxxxx     Mon Dec 17 14:31    /735140x "Xxx"
                          973 Xxxxx Xxxxxxxx        Mon Dec 17 16:44    /67735 "XX: xx Xxxxx Xx Xxxxxx"
                          974 Xxxxx Xxxxxx Xxxxx X  Tue Dec 18 06:39    /496007 "Xxxx Xxxxx Xxxxxx Xxx"
                          975 Xxxxxx Xxxxxx         Tue Dec 18 23:11    /346492 "Xxxx xxxxx Xxxxxx xxx"
                         A976 Xxxxx Xxxxxxxx        Wed Dec 19 10:54    /78214 "XX: xx Xxxxx Xx Xxxxxx"
                          977 Xxxxxx Xxxxxx Xxxxxx  Thu Dec 20 13:31    /291878 "Xxxx Xxxxxx Xxxxxx xX"
                          978 XXXX                  Thu Dec 20 16:29    /276557 "Xxxxxxxx Xxxxxxx (Xxx"
                         A979 XX XXXXXXXXXXX        Fri Dec 21 17:07    /55847 "Xx: XX Xxxxxxxxxxx Xxx"
                          980 xxxxxxxxxxxxxxxx_xxx  Sun Dec 23 10:56    /690275 "Xxxx xxx Xxxxxxx xxxx"
                          981 Xxxxx Xxxxxxx         Mon Dec 24 20:01    /4857  "Xxx xxxxxx xxxxxx"
                          982 Xxxxxx Xxxxxx Xxxxxx  Wed Dec 26 07:10    /572548 "Xxxx Xxxxxx Xxxxxx Xx"
                          983 Xxxxx Xxxxxxxx        Fri Dec 28 13:09    /23730 "Xxxxxxxxx xxxxx: xx Xx"
                          984 xxxxxxx@xxxxxx.xxx.x  Tue Jan  1 11:05    /55771 "Xxxxxxx xxx xxxx Xxxxx"
                         A985 Xxxxxxxxx Xxxxx       Wed Jan  2 18:35    /158255 "XX"
                          986 Xxxxxxxxx             Fri Jan  4 10:48    /11352 "Xxxx Xxxxxxxxx Xxxx"
                          987 xxxxxxx@xxxxxx.xxx.x  Sat Jan  5 11:04    /56865 "Xxxxxxx xxx xxxx Xxxxx"
                          988 xxxxxxxxx@xxxxx.xxx.  Mon Jan  7 17:41    /313675 "Xxxx Xxxxx xxxx xxx x"
                        &
                        $

                        They look identical to me.

                        • rvp replied to this.

                          pfr They look identical to me.

                          Well, they're identical because you probably also have set showlast in your ~/.nailrc. But, I don't see what's wrong here:

                          If you have new, unread mail, then mailx will position the message-list "window" to include those messages by default, and the current message pointer > will point to the first of those.

                          With no unread messages, mailx will, by default, position the window to include message #1 (and then you'll have to use the z command to page through windows); or at the window containing the last message if showlast is set. You can see this in my post #26, above.

                          Flagged messages--your message #970--in this respect, act like new messages for some commands: The Z command, for instance, will position the window to a list containing a new, or flagged, message. And, if a message is flagged, then > indicator will point to it in any window. If you unflag that message of yours, then the > will move to message #988.

                          • pfr replied to this.
                          • Jay likes this.

                            rvp Well, they're identical because you probably also have set showlast in your ~/.nailrc

                            Well actually, I remembered to comment it out before running each command.

                            rvp With no unread messages, mailx will, by default, position the window to include message #1 (and then you'll have to use the z command to page through windows); or at the window containing the last message if showlast is set. You can see this in my post #26, above.

                            So, basically I don't want showlast to be set then if I want my most recent mail to be in the first window? I simply want the mail to be displayed from most recently received (like most email clients) regardless of whether they are read or unread. Paging through multiple windows to get to my newest mail seems counterproductive.

                            If there really in no way around it then that is fine, I just find it a bit strange that it would not be possible as this is the standard way email clients display messages. Newest first, at the top of the list.

                            rvp Flagged messages--your message #970--in this respect, act like new messages for some commands: The Z command, for instance, will position the window to a list containing a new, or flagged, message.

                            I now wonder, is there an input command to ask mailx to show only flagged mail? I to flax/star important mail and this would help immensly if I could use such a filter in mailx.

                            • rvp replied to this.

                              pfr Paging through multiple windows to get to my newest mail seems counterproductive.

                              That's what the Z command is for.

                              pfr I simply want the mail to be displayed from most recently received

                              You can use set autosort=date which will sort every folder oldest -> newest when opened, then do a Z to jump to the end.

                              There's no sort method to do the reverse (newest first) either by sent or received date. Shouldn't be hard to do it though...

                              pfr is there an input command to ask mailx to show only flagged mail?

                              Section Specifying messages has :f to operate on flagged messages.