FAQ 3-8

Question 3.8

OK, reading news works now, but I want to be able to read my mail with Gnus, too. How to do it?

Answer

That’s a bit harder since there are many possible sources for mail, many possible ways for storing mail and many different ways for sending mail. The most common cases are these: 1: You want to read your mail from a pop3 server and send them directly to a SMTP Server 2: Some program like fetchmail retrieves your mail and stores it on disk from where Gnus shall read it. Outgoing mail is sent by Sendmail, Postfix or some other MTA. Sometimes, you even need a combination of the above cases.

However, the first thing to do is to tell Gnus in which way it should store the mail, in Gnus terminology which back end to use. Gnus supports many different back ends, the most commonly used one is nnml. It stores every mail in one file and is therefore quite fast. However you might prefer a one file per group approach if your file system has problems with many small files, the nnfolder back end is then probably the choice for you. To use nnml add the following to ~/.gnus.el:

(add-to-list 'gnus-secondary-select-methods '(nnml ""))

As you might have guessed, if you want nnfolder, it’s

(add-to-list 'gnus-secondary-select-methods '(nnfolder ""))

Now we need to tell Gnus, where to get its mail from. If it’s a POP3 server, then you need something like this:

(with-eval-after-load "mail-source"
  (add-to-list 'mail-sources '(pop :server "pop.YourProvider.net"
                                   :user "yourUserName"
                                   :password "yourPassword")))

Make sure ~/.gnus.el isn’t readable to others if you store your password there. If you want to read your mail from a traditional spool file on your local machine, it’s

(with-eval-after-load "mail-source"
  (add-to-list 'mail-sources '(file :path "/path/to/spool/file"))

If it’s a Maildir, with one file per message as used by postfix, Qmail and (optionally) fetchmail it’s

(with-eval-after-load "mail-source"
  (add-to-list 'mail-sources '(maildir :path "/path/to/Maildir/"
                                       :subdirs ("cur" "new")))

And finally if you want to read your mail from several files in one directory, for example because procmail already split your mail, it’s

(with-eval-after-load "mail-source"
  (add-to-list 'mail-sources
               '(directory :path "/path/to/procmail-dir/"
                           :suffix ".prcml")))

Where :suffix ".prcml" tells Gnus only to use files with the suffix .prcml.

OK, now you only need to tell Gnus how to send mail. If you want to send mail via sendmail (or whichever MTA is playing the role of sendmail on your system), you don’t need to do anything. However, if you want to send your mail to an SMTP Server you need the following in your ~/.gnus.el

(setq send-mail-function 'smtpmail-send-it)
(setq message-send-mail-function 'smtpmail-send-it)
(setq smtpmail-default-smtp-server "smtp.yourProvider.net")