Gnus for Mail and Newsgroups
To set up the Gnus mail feature, add the following lines to your .gnus file:
<pree> ;; Leave these two lines alone. (setq message-send-mail-function 'smtpmail-send-it) (setq send-mail-function 'smtpmail-send-it) ;; Customize the next three lines with your ISP information. (setq smtpmail-smtp-server "smtp.your-isp.com") (setq gnus-secondary-select-methods '((nnml "smtp.your-isp.com"))) (setq smtpmail-local-domain "your-isp.com")
You may have one e-mail address, or you may have several. If you have only one, include this line:
(setq mail-sources '((pop :server "your.pop3server2.com" :user "user" :password "password")))
If you have several, insert the following code to add a line for each e-mail address. They will be fetched in the order that you specify them here. Once fetched, all e-mail is treated more or less the same.
(setq mail-sources '( (pop :server "your.pop3server.com" :user "user" :password "password") (pop :server "your.pop3server2.com" :user "user2" :password "password2") ))
You don't have to include the password field. If you leave it off, though, you will be prompted to enter your password whenever you check for new mail.
Once all this configuration is done, try running Gnus, and it should fetch your mail. All mail will be dumped together into one pseudo-newsgroup. That's not the most helpful way for Gnus to act, but you need to give it more information in order for it to sort your mail intelligently.
Gnus treats your e-mail as one or more newsgroups, which is its power, because it will drop the mail into the groups you specify. Some groups will contain high priority mail; others will contain mailing lists that you only look at occasionally. You should establish a spam group and try and get Gnus to put all your spam there. Finally, there will be a catch-all group that collects the mail that doesn't fit anywhere else.
To create a mail group you have to specify its name and a regular expression. Mail that matches the regular expression will end up in that group.
The following simple example shows two groups, one for mail from email@example.com and another for all other mail.
(setq nnmail-split-methods '( ("mail.me" "^From:.*ed@telestoconsulting\\.com") ("mail.other" "")))
The first group, mail.me, will collect any message that has a line beginning with From: (the ^ indicates that this needs to be at the beginning of the line), and then contains any number of other characters, and then the string firstname.lastname@example.org. (Change this to your own e-mail address, of course).
Note the double slash (\\) in front of the dot between telestoconsulting and com. The double slash is necessary because the period character has a special meaning in Emacs regular expressions--it means zero or more of the following character. That's not what I want here, though; I want to match the string email@example.com exactly. To let Gnus know I want to match a literal period here, and not the special meaning of period in regular expressions, I need to insert the \\.
Regular expressions can become quite complex. To use a logical OR, parentheses and a vertical bar can be used. But these also need to be preceded by a double slash. For example, to have e-mail from both of my e-mail addresses dropped into the mail.me category, I can enter the following:
The regular expression now contains a sub-expression, which is delimited with parentheses \\(expression1\\|expression2\\). This line tells Gnus that when the From header is either expression1 or expression2, the mail should go in the me group. This gets a little confusing because expression1 and expression2 both need to contain \\ as they both contain a period. I still want those interpreted literally because it is part of the e-mail address.
The use of the parentheses and logical OR can be applied more than once in the regular expression. In the following example, I have a group called mail.ieee, which I want to use to collect all the incoming messages from IEEE. That includes any messages with IEEE in the address or subject line, as well as any mail from JWest, the local IEEE guy.
This regular expression looks for a line beginning with either To, CC, From, or Reply-To, followed by a colon, then followed by any number of any other characters (that's the .*), then either ieee or JWest@. (Sometimes JWest sends e-mail about IEEE from his work address, which doesn't have "ieee" in it.)
As you can see, regular expressions can get quite long. If they do, don't insert any line breaks;simply let the line wrap around in the editor. To make sure you can spot e-mail from friends, try this:
("mail.friends" "^From:.*\\(friend@myfriends\\.isp\\.com\\|friend2@myfriend2s \\.isp\\.com\\|friend3@myfriend3s\\.isp\\.com\\)")
The above regular expression will drop e-mail from three different e-mail addresses into mail.friends. The e-mail addresses are found in the parenthetically delimited list \\(e-mail1\\|e-mail2\\|e-mail3\\). It looks confusing, because once again I have to use a double slash before any period I want taken literally, and each e-mail address contains two such periods.
This is a great one if you get a lot of non-ASCII spam:
This regular expression tells Gnus to watch out for any e-mails with one or more non-ASCII characters in the subject line.
- New Products
- Readers' Choice Awards 2014
- Android Candy: Google Keep
- Handling the workloads of the Future
- How Can We Get Business to Care about Freedom, Openness and Interoperability?
- Days Between Dates?
- diff -u: What's New in Kernel Development
- December 2014 Issue of Linux Journal: Readers' Choice
- Computing without a Computer
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane