thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

Mail from Emacs - Part #1

β€’ 707 words β€’ 4 min β€’ updated

⚠️ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.

Whisper : Yeah, this is probably the most crazy thing I’ve ever done (with emacs, sure).

Overview #

I have a couple of e-mail accounts out there; this is inevitable nowadays. I usually manage them all from a single Gmail account, with a little help of POP3 or automatic e-mail forwarding (that depends on the relevance of the other mail accounts). The point is, while I don’t have to manually check every account – just the main one –, I still depend on the web interface of Gmail. In a scenario like this, two-step verification with Google Authenticator is a must. No problem, but what about mail clients? Currently I’m very happy with Claws Mail; it is simple and gets the job done. Thunderbird is not a software that I personally enjoy, but I find it great to set up (for example) for my family, since it is GUI friendly. Now, while Claws Mail is reasonably elegant, it is not something that I use in a daily basis. Not even in a weekly one. I only open it up sometimes, usually when I need (correction: want) to send a PGP signed message. Another thing is this year I became a reasonably active user of mailing lists: there are a couple of them that I read weekly. Reading them from gmail is a slow process (web or android, this doesn’t matter here).

Now, let’s get Gnus #

The previous section was intended to point out to you my motivation do to this. There is one more: curiosity. The hacker spirit of Linux/Emacs/(whatever) users is really special: sometimes we try out things just for the sake of trying them out. No strings attached, not a single reason to do them. This is divided in (at least, I hope) two parts. This one is only a ‘Hello World’ kind of setup. I don’t know yet how to operate Gnus properly (beyond its basics), so if you only want the technical details, go away – nah, just wait for the next post. EmacsWiki had all the information I needed to setup Gnus from Gmail. Seriously, I don’t need to duplicate everything here, just follow it. Briefly, you just have to create a $HOME/.gnus file for the configuration of Gnus (the mail client (embedded) inside emacs we are using here) and a $HOME/.authinfo for your Gmail password. I really hope you are using two-step auth here, otherwise you’ll be storing your default Gmail passwrod as plain-text in your filesystem. Please don’t do that. As an additional layer of security in the case your *nix box is shared with another user, it won’t hurt if you do

chmod 700 $HOME/.gnus
chmod 700 $HOME/.authinfo

to keep those files only available to you. Next, to make sure your e-mail is working, do a M-x gnus. You should see there your labels from gmail. Yay! Now, do a C-x m to send a new e-mail. By doing this, you’ll be creating a new buffer with the following contents:

To:
Subject:
From: (myawesomefullnamehere) <(myawesomeemailhere)@gmail.com>
--text follows this line--

--

β€” Thiago

Pretty neat, huh? It even took my signature from $HOME/.signature, that I use for Claws Mail. However, about the ‘From’ line, I suspect it parsed the contents of the two user-full-name and user-mail-address variables that I have set on my $HOME/.emacs file. I just sent a sample e-mail and saw it worked. Cool, dude!

Now, there are so many things to do / discover here. Here is a mini org list to remind myself later:

* Sending mails
β€” [ ] attachments
β€” [ ] PGP signing
β€” [ ] PGP encryption
β€” [ ] multiple e-mails
β€” [ ] CCo
β€” [ ] Integration with other emacs features: spell-checking, auto-fill,
  etc.
β€” [ ] Plain text only?? What if I want to send a org or markdown mail?
  This would be super cool.
* Managing mails
β€” [ ] Delete one mail
β€” [ ] Delete several e-mails
β€” [ ] Searching for old e-mails (this is probably better with the gmail
  interface...)
β€” [ ] Change a label
β€” [ ] Mark mails as {un,}read
β€” [ ] Sync mails periodically
β€” [ ] Sync mails manually

For starters, this is okay. Until later.