Sunday, May 22, 2011

gmail integration with emacs

I think it is fun to have Emacs act as your mail client. It's like when u are busy writing code, and you got to send in some snippets or a quick mail on the issue, you just don't leave the editor!. So here is how you integrate Emacs to access your Gmail compose. Note, your mails sent from Emacs are also stores in the "sent" label on your Gmail!

pre-requisites
  1. emacs 23.2
    Use the latest version of emacs, I used emacs23.2 while i made the customization.

    download emacs from http://ftp.gnu.org/gnu/emacs/

  2. gnutls
    gnutls is the gnu transport layer security library which ensures secure client/server communication over the transport layer.

    http://www.gnu.org/software/gnutls/gnutls.html for more info on gnutls

     
  3. Libgcrypt
    To build gnutls, this package may be required it is provided in the gnutls download link along with gnu tls. One might have to download it separately.

The .authifo File

  1. The authinfo file stores the login information for the mail account. Create the .authinfo file
     
  2. Insert the following line into the .authinfo file which u can create and place in the ~/. directory

    machine smtp.gmail.com login @gmail.com password

     
  3. Modify the permissions of the .authinfo file as follows

    chmod go-rwx .authinfo

    chmod u+rw .authinfo

Emacs Init Config (.emacs)

Add this section to your .emacs

;; email setting for my emac
(setq send-mail-function 'smtpmail-send-it
message-send-mail-function 'smtpmail-send-it
smtpmail-starttls-credentials
'(("smtp.gmail.com" 587 nil nil))
smtpmail-auth-credentials
(expand-file-name "~/.authinfo")
smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 587
smtpmail-debug-info t)


Sending mail
The keybinding for emacs to send mail is
  1. C-x m to compose mail 
  2. C-c C-c to send mail when you are done composing the mails

Thanks
Shyam

No comments:

Post a Comment