Avatar of jl66
jl66
Flag for United States of America asked on

How to dump/get mail list to a file on Linux

If I type mailx in console, it shows that

....
 U 17 J1.smith@A.com  Fri Mar 30 14:38  88/5740  "Re: Test1"
 U 18 J2.king@B.com  Fri Mar 30 16:50  56/3244  "Please read this one"
 U 19  J2.king@B.com Mon Apr  9 11:03 236/11783 "Server Failure"
....

Is there any way to dump all the lines above to a file? I do not need the email body, but need all the lines.
Do any gurus shed some light on it?
Email ServersLinux

Avatar of undefined
Last Comment
jl66

8/22/2022 - Mon
woolmilkporc

Try

mailx -H > outputfile
woolmilkporc

Did you read the above suggestion? Sorry, I've updated the comment, so you might not have received a message.
jl66

ASKER
Thanks for offering the tip. Unfortunately, it did not work on my system. Have you tried it?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
woolmilkporc

Yes.

mailx -H

lists all the headers in my mailbox.
woolmilkporc

Well,

I'm running Unix (AIX).

In some other systems I found

mailx -P

working better than "mailx -H".
ASKER CERTIFIED SOLUTION
woolmilkporc

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jl66

ASKER
An equal question is that in mail box ie /var/spool/mail (a file), I expect it contains everything on mail. Which variable is for NEW emails and the emails that have been read?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
jl66

ASKER
Thanks for the update.
Unfortunately in our system, there is no -H option.
I tried to get something in the following way:

1) tail -f /var/spool/mail   #(mail box file).
2) send a mail to this linux server.
3) immediately a lot of messages shown on screen via tail -f.

The email software updates the file when any new email arrives. If I try mailx, it shows the mail I just sent >N ...., which is a new mail. I guess in the file /var/spool/mail there is some place to store this info ">N", or there is some other queue file to store it. How to find it?

Our system is redhat: 2.6.18-274.7.1.el5
woolmilkporc

All files in the mailbox are "new", usually,

Files which are not "new" go to ~/mbox, as I already wrote above.
jl66

ASKER
Very helpful. Close to what I wanted.
Your help has saved me hundreds of hours of internet surfing.
fblack61