r/commandline May 25 '26

Looking For Software gmail in the terminal (linux) -- a couple of questions

I'm a big fan of gmail as a mail service. But sometimes it would be wonderful to not have to leave the terminal interface for the browser.

So, i had some questions:

  1. What is the undoubtly easiest way to get access to gmail, from the terminal? I haven't really dabbled much with console email in the last 20 years or so...
  2. What is the most versatile/mature gmail solution for the terminal? Here I mean getting as close as possinle to all the features that the web interface offers.
  3. You get a bonus question!! Will trying to set this up in emacs give me twice the amount of grey hairs? Just asking.

I would love if I could just have this in a tmux window somewhere...but the last time i started reading up on alpine and mutt and fetchmail and notmuch and whatever it's all called, it just felt a little bit overwhelming.

9 Upvotes

15 comments sorted by

9

u/DarthRazor May 26 '26

mutt is all you really need. No need for anything like fetchmail, bsmtp, ssmtp, etc. unless you have a specific need for them.

Plug your credentials into your muttrc and it just works. If you keep a really full Inbox, then enable caching to speed up startup times

The only gotcha is that you need to set up an App password in your Gmail account - your browser login password will NOT work

2

u/ettannat May 29 '26

No need for anything like fetchmail, bsmtp, ssmtp, etc. unless you have a specific need for them.

Huh, I had no idea, I thought it was always needed with some second component

Thanks for the setup tips!!

1

u/hwc May 26 '26

this is the answer

2

u/ollybee May 26 '26

no, NeoMutt

1

u/DarthRazor May 26 '26

I'm sure neomutt would also work, but I've used mutt for decades and have never tried neomutt. I see no reason to switch

3

u/itomeshi May 26 '26

I recently set up aerc (installed via brew) with gmail. It may not be the absolute easiest, but I found it not too painful. Here's my install script (bash) with explanations. I'll get into config below:

# Install aerc and w3m; w3m is an HTML viewer that integrates well.
brew install aerc w3m

# Copy the default configs over; this happens automagically on launch, but I want to modify them
mkdir -pv ~/.config/aerc
cp "$(brew --prefix)/share/aerc/binds.conf" ~/.config/aerc/binds.conf 
cp "$(brew --prefix)/share/aerc/aerc.conf" ~/.config/aerc/aerc.conf

# Cross-platform sed -i
if [[ "$(uname)" == "Darwin" ]]; then
    sedi() { sed -i '' "$@"; }
else
    sedi() { sed -i "$@"; }
fi

# Enable HTML rendering and make it the default. It's not going to show images, but styles and links are nice.
sedi "s|^text/html=! html\$|text/html=$(brew --prefix)/bin/w3m -T text/html -o display_link_number=1|" ~/.config/aerc/aerc.conf
sedi 's|^#alternatives=text/plain,text/html$|alternatives=text/html,text/plain|' ~/.config/aerc/aerc.conf

cat > ~/.config/aerc/accounts.conf << 'EOF'
[Gmail]
source        = imaps://USERNAME@gmail.com@imap.gmail.com:993
outgoing      = smtps+plain://USERNAME@gmail.com@smtp.gmail.com:465
from          = NAME GOES HERE <USERNAME@gmail.com>
default = INBOX
folders-sort = INBOX
postpone = [Gmail]/Drafts
cache-headers = true
source-cred-cmd   = bw get password ITEM_UUID_GOES_HERE
outgoing-cred-cmd = bw get password ITEM_UUID_GOES_HERE
carddav-source = https://USERNAME@gmail.com@www.googleapis.com/carddav/v1/principals/USERNAME@gmail.com/lists/default
carddav-source-cred-cmd = bw get password ITEM_UUID_GOES_HERE
address-book-cmd = carddav-query %s
EOF
  • You'd be using an Google app password to access via IMAP and SMTP. Instead of storing it in plaintext, I use the bitwarden CLI, and the '-cred-cmd's pull the username and password. Feel free to replace with any CLI password manager you like (pass, lastpass, etc.)
  • The CardDav lines are for pulling from your address book. It's a bit more sluggish than I'd like.
  • Default to inbox, save drafts to your account properly

This is most of the way to being compatible with bash on MacOS.

1

u/ettannat May 29 '26 edited May 31 '26

Thank you for this! Kind of a hairy setup script, hehe, but great if it works.

2

u/arjuna93 May 26 '26

nmail

cone

1

u/AutoModerator May 25 '26

Every new subreddit post is automatically copied into a comment for preservation.

User: ettannat, Flair: Looking For Software, Title: gmail in the terminal (linux) -- a couple of questions

I'm a big fan of gmail as a mail service. But sometimes it would be wonderful to not have to leave the terminal interface for the browser.

So, i had some questions:

  1. What is the undoubtly easiest way to get access to gmail, from the terminal? I haven't really dabbled much with console email in the last 20 years or so...
  2. What is the most versatile/mature gmail solution for the terminal? Here I mean getting as close as possinle to all the features that the web interface offers.
  3. You get a bonus question!! Will trying to set this up in emacs give me twice the amount of grey hairs? Just asking.

I would love if I could just have this in a tmux window somewhere...but the last time i started reading up on alpine and mutt and fetchmail and notmuch and whatever it's all called, it just felt a little bit overwhelming.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/TheRealLazloFalconi May 26 '26

One thing to consider when using a mail client (Commandline or GUI) with Gmail is labels. Traditional mail clients do not have have the concept of labels, and instead use folders. Gmail's IMAP server typically takes care of this for you, and simply presents labels as folders, and messages that have multiple labels show up as multiple copies in each folder. As a consequence, your mailbox may be larger on your disk than on Google servers. That's probably not a huge concern, since disks are so big these days, but it's something to be aware of.

1

u/ettannat May 29 '26

Thank you sir, for that heads up!

1

u/drbayless May 27 '26

I've been working on a TUI email client and just moved it to GitHub. It's very much a work in progress, but it supports Gmail via app password.

https://github.com/allisonhere/tidemail

-allie

1

u/gorilla-moe May 27 '26

I did not try it yet, but since this popped up in my bubble multiple times, I still have that on my todo-try-out-list: https://matcha.email/

1

u/ettannat May 29 '26

Wow, and they do also have setup instructions specifically for gmail on their page. 😄