(The question was about generally accessing email via the terminal, before the question poser specified getmail
, but attachments are easily saved in Mutt
also: see my note below)
You could use the program Mutt
, which is available in the repositories. I have found that Mutt
is highly configurable and fairly straightforward once you get used to it. The following instructions refer to setting it up for gmail
using the imap
and smtp
protocols (make sure imap
is enabled in your gmail
account settings ).
It takes a little while to set up, but here's basically the quickest way to do it:
- Make a directory called
.mutt
and within that create another one called cache
Next create a file called .muttrc
to store your settings, although this does not go in the .mutt
folder, but just in your home folder. Then enter the following settings in there; for the password I have left it ""
so that you are prompted, as it's not a good idea to put your password in a plain text file like .muttrc.
(Note: these settings are based on the Linux Format article on Mutt, LXF134, August 2010, pp. 96-97.)
set from = "[email protected]"
set realname = "Your Name"
set imap_user = "[email protected]"
set imap_pass = ""
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
set trash = "imaps://imap.gmail.com/[Gmail]/Trash"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set smtp_url = "smtp://[email protected]:587/"
set smtp_pass = ""
set move = no
set imap_keepalive = 900
set sort=threads
set sort_aux=date
Now with your settings saved in .muttrc
, just type mutt
in the terminal and enter your password when prompted. I have tested these settings and they work fine; look around for more settings to customise your Mutt
experience, as macros can be used with the program to give it extra functionality. See the Mutt manual for this and more, which is also installed when you get the program.
To open attachments, select the message with the attachment, press v
, select the attachment and press enter
to view it in your default application. To save the attachment instead press s
to save and enter a file name and location and press enter
.