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?
2 Answers
Your best bet is to use fetchmail to retrieve your email from your gmail account via POP3.
Install fetchmail:
sudo apt-get install fetchmail
(Or equivalent)
Then save this in a .fetchmailrc file in your home directory):
# set username
set postmaster "yourlocalusername"
# set polling time (5 minutes)
set daemon 600
poll pop.gmail.com with proto POP3
user '[email protected]' there with password 'yourgmailpassword' is yourlocalusername here options ssl
Substituting your gmail user & password and your local username.
Then kick off fetchmail
to start it.
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
and again here: http://www.axllent.org/docs/networking/gmail-pop3-with-fetchmail/
If you would prefer to use the IMAP protocol, replace:
poll pop.gmail.com with proto POP3
in the fetchmailrc file with:
poll imap.gmail.com with proto IMAP
However YMMV...Google's IMAP implementation is known to deviate from the norm, so you may end up with unexpected results.
-
2I personally wouldn't use POP3 protocol. POP3 is a good model for "I have one machine/device for email" With multiple machines you get multiple views of email, with some mail here, some there. Commented Mar 25, 2013 at 17:16
-
1
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.
If you just want something you can run in a terminal, I'd suggest mutt, or pine.
-
That's because at my office they use AIX OS(unix based OS) and we don't have permission to install any other software so we are left with only mail/mailx. Commented Apr 15, 2013 at 17:37