I searched Google a lot but all I found were the tutorials to send messages using mail/mailx command.I want to receive gmail messages using mail/mailx.Is it possible?
Your best bet is to use fetchmail to retrieve your email from your gmail account via POP3.
Then save this in a .fetchmailrc file in your home directory):
Substituting your gmail user & password and your local username.
Then kick off
Once your mail has been retrieved to a local copy on your machine, you can read it using a wide range of mail clients (including mailx).
There is a quick tutorial here: http://mohan43u.wordpress.com/tag/mailx/
and again at lifehacker: http://lifehacker.com/235207/geek-to-live--back-up-gmail-with-fetchmail
If you would prefer to use the IMAP protocol, replace:
in the fetchmailrc file with:
However YMMV...Google's IMAP implementation is known to deviate from the norm, so you may end up with unexpected results.
I'd ask "why mail/mailx"? Why specifically?
It's built with an old model of email, back when machines were expensive so you usually only had one machine to read mail from so you didn't have to worry about synchronizing across machines. Having it now kind of pins you to a specific machine that has old mail on local files.
Besides that, the UI is ancient, and hard for most people to navigate.