rule #1 abuse the hell out of emacs, you will learn to love it.
so lets get into how to do email, the Right Way[tm]
I have 4 imap , 2 pop, and 3 nntp accounts. Its a mess. I hate email. Why not make the best of a bad situation and make getting email interesting and almost fun?
Setting up the imap accounts is as simple as reading http://www.lysator.liu.se/~forsberg/docs/Gnus_and_Courier.html and http://my.gnus.org/node/225. Merge the two together into some semblence of a working config. It takes lots of tinkering.
First thing is first
Setup the basics, like the default from address and your sent folder:
(setq user-mail-address “email@example.com”)
(setq mail-host-address “example.com”)
(setq gnus-message-archive-group “nnimap+user1:INBOX.Sent”)
(setq gnus-outgoing-message-group “nnimap+user1:INBOX.Sent”)
If you notice, which might be clearer later on, is the way we reference a folder on imap, or really any group/folder. select-type+name:namespace.folder. So the sent folder is specified via: use imap with the select-method name of “user1″ and put it in the Sent folder. Each imap server has its own namespace. This is something you have to find out on your own…. I use courier-imap so my namespace is INBOX
Wait, don’t delete that
I don’t want my mail to go away just because I read it. So the magic to keep your mail, unless explicitly marked to expire is:
(setq nnmail-expiry-wait 2)
(remove-hook ‘gnus-mark-article-hook ‘gnus-summary-mark-read-and-unread-as-read)
(add-hook ‘gnus-mark-article-hook ‘gnus-summary-mark-unread-as-read)
Its magic, really. and don’t try to make sense of it, half of gnus is designed solely to confuse you.
Where things are
We probably should setup the accounts now. I set the nntp as the first select, and the imap accounts as secondary… no idea why, but it works:
(setq gnus-select-method ‘(nntp “news”
The first string in the account list is just a name, which makes it easier to refer to it in other places. You can name it anything you want, I just keep it to the login name of the account. The nnimap-nov-is-evil is a cache improvement, think speed. nnimap-search-engine is a cool little thing to help you find emails, more on that later. nnimap-authinfo-file is where the authorization info is stored, it looks like:
machine mail.example.com login user1 password user1-password
I have a different authinfo file for each account because gnus can only differentiate multiple lines by machine name, not account name. So I find it simple to just keep one line in each file and have a single file for each account.
Making the Mess Messier
Splitting, this is weird and takes some getting use to, and its not really explained well anywhere. I doubt it is even possible to explain well at all. Splitting boils down to what is commonly referred to as “filters” only much much much more powerful. Here is some courier specific magic that will make things work as you ‘expect’ them to:
(setq nnimap-split-inbox ‘(“INBOX” ))
(setq nnimap-split-predicate “UNDELETED”)
(setq nnimap-split-crosspost nil)
Finally a snippet from my split:
’((“user1″ (“INBOX” nnimap-split-fancy))
(“user2″ (“INBOX” nnimap-split-fancy))
(“X-Spam-Flag” “YES” “INBOX.Junk”)
;;I snipped a lot of rules out here
(“List-Id” “.*news.jabber.org.*” “INBOX.jabber.news”)
(“^\\(Delivered-\\)?To” “\\(.*\\)-\\(.*\\)@example.com” “INBOX.alias.\\2″)
We are running the nnimap-split-fancy rules on the user1 and user2 accounts, specifically on the INBOX folder.
- The first rule says that, if there is a header named X-Spam-Flag and its value is YES then put it in the current account’s Junk folder
- The second rule says that, if there is a header named List-Id and its value containes news.jabber.org move it to jabber.news folder
- The last rule is some lispy regex magic. It boils down to: if the mail was sent to firstname.lastname@example.org then put it in alias.word2 folder. I have an alias system in that if I send an email or subscribe to some list then I create an alias, email@example.com
- The last is just the “it didn’t match any rules, dump it here”. The ‘here’ I call unsorted
If you want to become really confused read the manual on fancy splitting
Where fore art thou?
I have a lot of email stored away in my imap accounts. I like to find things once in a while, this is where nnir comes in. You mark groups to search via # in the group buffer, G-G and enter the query. *poof* matching emails. good stuff. M u to unmark the group.
Me, Myself and I
With all my aliases, I like to keep people guessing as to who they are talking to. Posting styles are really useful. Read the section in the manual its simple.
This is not a complete solution to what I would like to do, and I have yet to find a way to customize it like split-fancy. I would like to be able to create more complex rules to determine values for autofill.
Just get it already
Its nice to have email pulled automatically without having to press ‘g’ in the group buffer . (yes I am that lazy). This is where gnus-demon comes in. You can read the manual but it doesn’t really help. So here is the elisp to do it:
(setq gnus-use-demon t)
(gnus-demon-add-handler ‘gnus-group-get-new-news 10 2)
Once emacs is idle for two minutes, it will pull all new emails, posts, whatever every ten minutes, e.g. it presses ‘g’ for you.
The outside world
What? you want to send email too? thats just asking too much.
I had to put this in my ~/.emacs file, it wouldn’t work in ~/.gnus.el for some odd reason
(setq send-mail-function ‘smtpmail-send-it)
(setq message-send-mail-function ‘smtpmail-send-it)
(setq smtpmail-default-smtp-server “mail.example.com”)
(setq smtpmail-smtp-server “mail.example.com”)
The Fat Lady
Thats it for now. It should be enough to get gnus up and running. I didn’t bother with pop, because thats just too easy. I was having problems posting to nntp servers, I think its fixed, not sure.
- Figure out a better spam system. I am using spamassassin with qmail (another post?). I would liked to type ‘S’ or ‘J’ or whatever, have the mail move to INBOX.NewJunk and have a server side script periodically make spamassassin learn from the contents of that directory.
- there is this thing called gnus-alias, which is supposedly better than posting styles, but its outside of my package system (gentoo) and there are no docs. Or at least none that I have found.
- gnus-registry is suppose be some kind of address book. I poked it once, it yelled at me, I ran away. I would really like to get that setup.
- I am still getting stuck with stupid simple things. How do put multiple addressess im the To header. To: firstname.lastname@example.org,email@example.com is delivered to user1 but not user2… why?
Things that suck:
- gnus-get-new-news blocks emacs. This means that if you are chatting in erc and gnus gets mail, you are frozen until its done. side effect of using a text editor as an email client
- gnus is a news reader first, mail read second. as such, tasks that should be simple are really mind boggling complex for mail. that and some things are not documented well at all.
There is my first attempt to document my travels through the land of gnus. Its an interesting trip…
Finally, for your reading pleasure a gnus example config file. This is just a sanitized version of mine.