Select mailbox "sent mail" or "all mail" in Ruby Net::IMAP

The "sent mail" folder will differ from provider to provider. Gmail's "sent mail" folder is named "[Gmail]/Sent Mail". Select that instead and it'll work.

imap.select('[Gmail]/Sent Mail')

FYI, Gmail's system folders are the following:

  • INBOX
  • [Gmail]/All Mail
  • [Gmail]/Drafts
  • [Gmail]/Sent Mail
  • [Gmail]/Spam
  • [Gmail]/Starred
  • [Gmail]/Trash

You can find the names of all folders with:

imap.list('*', '*') 

The Gmail folders name's will change depending on the user selected language. So in Spanish for example:

"[Gmail]/All" Mail will be "[Gmail]/Todos"


I found the following to be helpful (ruby 2.0.0-p195)

# list all folders
imap.list '', '%'

Tags:

Ruby

Gmail

Imap