2009年6月13日星期六

Configuration of Gmail on Gnus/Emacs (Ubuntu Gutsy)

I tried configuring Gnus/Emacs to send/receive mails through Gmail using IMAP/SMTP protocol on my Ubuntu-Gutsy Linux Box.

Emacs Version: 22.1.1
Gnus Version: 5.11

I performed the following steps:

  • I had to install sendmail and starttls programs using apt-get first and start sendmail service.

  • Enable IMAP support for your Gmail account online as described here :
    http://mail.google.com/support/bin/answer.py?answer=77695


  • Create a file named .gnus.el in your home directory and copy the configuration as given below:


    ;; Configuration of ~/.gnus.el

    ;; Customize the next three lines with your ISP information.
    (load "starttls")
    (load-library "smtpmail")

    (setq user-mail-address "username@gmail.com")
    (setq user-full-name "User Name")

    ;; Configure incoming mail (IMAP)
    (setq gnus-select-method '(nnimap "gmail"
    (nnimap-address "imap.gmail.com")
    (nnimap-server-port 993)
    (nnimap-authinfo-file "~/.imap-authinfo")
    (nnimap-stream ssl)))

    ;; Configure outbound mail (SMTP)
    (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
    smtpmail-smtp-server "smtp.gmail.com"
    smtpmail-default-smtp-server "smtp.gmail.com"
    send-mail-function 'smtpmail-send-it
    message-send-mail-function 'smtpmail-send-it
    smtpmail-smtp-service 587
    smtpmail-auth-credentials '(("smtp.gmail.com" 587 "username@gmail.com" nil))
    smtpmail-debug-info t
    smtpmail-debug-verb t
    )
    (setq smtpmail-local-domain nil)
    (setq gnus-permanently-visible-groups "gmail")
    (executable-find starttls-program)

  • Create another file named .imap-authinfo in your home directory with the following line:

    machine imap.gmail.com login username@gmail.com password my_password port 993

  • Now, start Emacs, and type M-x gnus to launch Gnus. Gnus should automatically check for email on Gmail.com. After a while, when gnus process completes it displays a list of subscribed mailboxes. By default, you are subscribed to nndoc+gnus-help:gnus-help mailbox only.

  • To add your Gmail INBOX and other Gmail Labels you need to add them as mailboxes. Type 'U' in the Gnus Group Buffer and type the name of the Gmail Label or type INBOX to subscribe that Label to Gnus. You can also use auto-completion feature here to list all labels.

  • Now, you should see the subscribed Mailboxes in the Groups buffer. You can press 'Enter' on any mailbox to read mails under that label.

  • To send an email, type 'm'. You should get a buffer to send email. Remember here that it will prompt you to enter your password to send emails every time. If you wish to skip this step, change the value of smtpmail-auth-credentials variable in .gnus.el file you just created :

    smtpmail-auth-credentials '(("smtp.gmail.com" 587 "username@gmail.com" "password"))

  • You can change the permissions on the file .gnus.el and .imap-authinfo to restrict the access to your username only.

  • chmod 700 ~/.gnus.el ~/.imap-authinfo
All the above steps must configure Emacs to send and receive email using Gmail successfully. Hope this helps!

没有评论:

发表评论