Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How do I use the mail command to check email (and send email) from gmail. Does it support labels? I couldn't have figure out where to put the username and password. I tried to search for instruction but couldn't find any

share|improve this question

4 Answers 4

The mail command is an old and primitive mail client. It only supports reading mail locally on a unix server, typically stored in mbox format in /var/mail or a similar location.

To read Gmail mail, you need to either use their web interface, or use a client that works with Gmail's POP3 or IMAP access, or use the unmaintained Gmailfs (not recommended for inexperienced users). I recommend IMAP (make sure that you've enabled IMAP access in your account).

There are many email clients that support IMAP. On the command line, you could use Mutt, Sup, one of the Emacs mail clients, or many others. Just about any GUI mail client supports IMAP. IMAP only defined folders, not labels (the difference is that a mail is only in one folder but can have many labels); not all good IMAP clients are good at managing labels, and I don't know what clients support labels well.

Another approach would be to have Gmail forward all mails to your machine. But that requires an always-on, always-connected machine, and some technical know-how. I don't recommend this for an inexperienced user. And I'd recommend a more modern mail client than mail anyway.

share|improve this answer
    
I tried to configure gnus (emacs client) to access gmail but I couldn't have figure which file to use. I followed this link –  Yotam May 6 '11 at 19:18

Three parts:

  1. On the GMail account, enable POP.
  2. Install a local-only SMTP server that sends mail through another SMTP server.
  3. Install/configure fetchmail.

After you have successfully installed and configured an SMTP server to relay mail though GMail (or any other SMTP server that is available to you), install and configure fetchmail.

GMail will arrive locally when fetchmail hands it off to the local SMTP server for delivery. Postfix might be a good/easy/quick choice for an SMTP server.

There are better mail clients, like mutt, but, reading mail is simple, just type mail to load the interface. Composing mail: mail someone@somewhere.com and finish the mail with a single . on a blank line.

There is no os/version in the question/tags to write anything more specific.

share|improve this answer

mail -s "Subject of the mail" username@example.com

share|improve this answer
2  
This doesn't answer the question: the OP wants to use mail to check and send mail from their Gmail account; your command does not acheive that. –  jasonwryan Jan 21 '13 at 7:33

Another option would be to use fetchmail to pull the mail from Gmail and put it in the local mbox file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.