Gnus

From DreamHost

Jump to: navigation, search

Gnus is a major mode for GNU Emacs that can be used to read and send email.

Contents

Setting up Gnus

Gnus stores information about a user's mail and news accounts in a file called .gnus.el in his or her home directory. To configure Gnus to use your Dreamhost email account, launch Emacs and open this file with C-x C-f ~/.gnus.el. The following sections walk through the information that needs to be added.

In the code shown below, replace "example.com" with the name of your own domain, and "John Smith" and "jsmith@example.com" with your name and email address, respectively.

This example configuration uses SSL and TLS to connect securely to the Dreamhost mail server. You'll need OpenSSL and GnuTLS installed for this to work.

Specifying user information

Configure your email address and name by adding this block of code to the top of the file:

(setq user-mail-address "jsmith@example.com"
      user-full-name "John Smith")

Reading email using IMAP

Gnus represents sources of incoming mail and news using what it calls select methods. Each select method specifies a protocol, a name, and a set of parameters that tells Gnus how to connect to the source. There is always one native method, which Gnus opens automatically on start up, and there can be any number of secondary methods that specify additional sources.

If you'll be using Gnus only to read your Dreamhost mail, add this block of code to make your mail server Gnus' native method:

(setq gnus-select-method
      '(nnimap "example.com"
                (nnimap-address "mail.example.com")
                (nnimap-server-port 993)
                (nnimap-stream ssl)))

If you've used Gnus before and already have a native method defined, use this block of code instead to add your mail server as a secondary method:

(add-to-list 'gnus-secondary-select-methods
             '(nnimap "example.com"
                      (nnimap-address "mail.example.com")
                      (nnimap-server-port 993)
                      (nnimap-stream ssl)))

Sending email using SMTP

Add the block of code below to have Gnus use GnuTLS to connect securely to your SMTP server. Note that we need to pass the --insecure option to GnuTLS so it will allow the connection even though the server's hostname and certificate do not match.

(setq starttls-use-gnutls t
      starttls-gnutls-program "gnutls-cli"
      starttls-extra-arguments '("--insecure"))

Next, configure Gnus to send mail using Emacs' SMTP library, and to connect using TLS authentication to port 587 of the server:

(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-smtp-server "mail.example.com"
      smtpmail-default-smtp-server "mail.example.com"
      smtpmail-smtp-service 587
      smtpmail-starttls-credentials '(("mail.example.com" 587 nil nil))
      smtpmail-auth-credentials '(("mail.example.com" 587 "jsmith@example.com" nil))
      smtpmail-local-domain "example.com")

The nil as the last parameter to smtpmail-auth-credentials will force Emacs to prompt you for your password when it's needed. To avoid this prompt, you can replace the nil with your password in double quotes (but be careful then to secure this file!).

Testing Gnus

Save this file with C-x C-s, then launch Gnus by typing M-x gnus. If you configured the native method to be your IMAP server, Emacs will automatically connect to it, prompting you for your username and password.

If everything succeeds, you'll see the Group buffer next. Your mail folders won't be visible right away; you'll need to explicitly subscribe to them first. (Try typing U, then INBOX.) To exit Gnus, type q at the Group buffer. See the Gnus tutorial for help getting started, or the Gnus Manual for complete information.

External links

Personal tools