Tuesday, April 01, 2014

Getting Back In Touch With My E-mail Roots - A Little Gmail Integration With Emacs

For the majority of my e-mail consuming life, I lived in emacs. First RMAIL, then Gnus. I was threading conversations before Gmail was a glint in anyone's eye. These days, though, I live in the Gmail universe (whether it's Google Apps for business or plain old Gmail for personal). And for the most part, life is good. Every once in a while I'll consider switching back to using emacs full time, but it just doesn't seem like the benefits are there (heresy, I know).

Then it hit me: maybe I can get some benefits of e-mail from emacs (mainly, super quick access without having to lift my fingers off the keyboard) without doing a big switch. That is, configure emacs for sending of e-mail and not worry about the reading side of things.

A quick Google search turned up this configuration, and I thought my setup was going only require a few seconds of work. Alas, it wasn't so simple.

I ran into a number of issues: First, Google requires either SSL or TLS encryption for sending of e-mail. I spent a bunch of time trying to get GnuTLS to run on my Windows environment. It seems like all the pieces are there, but I kept running into issues. While I was fiddling with this, I ran into another problem: Verizon FIOS blocks outgoing port 25. Not a huge deal, as you can switch to port 587, but it did cause me to scratch my head as to why my connection was just timing out.

Finally, as I was just about to give up on my dreams of emacs e-mail, I remembered that I've got a second option for encryption: SSL. I went ahead and installed stunnel as a Cygwin package and setup the following configuration:

# Inspired by: https://www.stunnel.org/pipermail/stunnel-users/2012-April/003695.html 
client = yes
output = stunnel-log.txt
debug = 7
options = NO_SSLv2
options = NO_SSLv3

# SERVICE-LEVEL OPTIONS
[SMTP Gmail]
 accept = 465
 connect = smtp.gmail.com:465

I then kicked off stunnel and set the following up in emacs:

(setq send-mail-function 'smtpmail-send-it)
(setq smtpmail-smtp-server "localhost")
(setq smtpmail-smtp-service 465)
(setq user-mail-address "ben@ideas2executables.com")

I was then able to hit Control-x m, type a message and hit Control-c Control-c to send it off. Emacs prompted me for my SMTP credentials (which is my gmail login) and to my shock and amazement, it worked.

I can now tap out quick message from emacs, all without messing with my existing e-mail setup. It may not be as exciting as the day I finally got Gnus setup the way I wanted it, but it's a step in the right direction.

5 comments:

  1. Excellent! Thanks for writing this up. I have a Windows machine at work (with cygwin) and I will try this soon.

    ReplyDelete
  2. Rick - let me know how it works out. I still need to automate the starting of 'stunnel' - but I figure that can't be that hard to do.

    ReplyDelete
  3. And when you want to read your Gmail-email in Emacs as well, you can always configure Gnus as an IMAP client.

    ReplyDelete
  4. Anonymous4:09 PM

    I have both Gmail and work mail running fine in Emacs by using Wanderlust. It's in el-get. Works like a charm, and many good tutorials on emacs-fu and emacs wiki.

    ReplyDelete
  5. I had success sending mail from emacs on windows using 'fake sendmail' http://www.glob.com.au/sendmail/

    ReplyDelete

LinkWithin

Related Posts with Thumbnails