NOTE: Work in progress. Please add/modify code to improve the examples.
This page describes how to manage multiple email accounts with wanderlust, one of them being a Google mail account.
The .folders file tells wanderlust how to represent the folders. The following is an example of using just IMAP folders, as opposed to download the emails (e.g. with offlineimap) for permanent storage. Note that even when you just use IMAP folders wl downloads the messages you read (and the one following) and cache them locally to ~/.elmo/cache.
On Gmail, the default system folders (sent, trash, etc) are locale specific, i.e. the name depends on your language settings in gmail, and these folders are placed in the folder “[Gmail]”. Folders (called “filters” by Gmail) are delimited by “/”.
In the example of the other domain (company.com), the username is an email address itself and must be in quotation marks.
~/.folders:
# -*- conf-unix -*-
GMAIL{
%INBOX:myname/clear@imap.gmail.com:993! "In"
%[Gmail]/Sent:myname/clear@imap.gmail.com:993! "Sent"
%[Gmail]/Draft:myname/clear@imap.gmail.com:993! "Draft"
%[Gmail]/Trash:myname/clear@imap.gmail.com:993! "Trash"
%[Gmail]/Spam:myname/clear@imap.gmail.com:993! "Spam"
Buy{
%buy/ebay:myname/clear@imap.gmail.com:993! "E-bay"
%buy/records:myname/clear@imap.gmail.com:993! "Records"
%buy/books:myname/clear@imap.gmail.com:993! "Books"
}
Friends{
%friends/work:myname/clear@imap.gmail.com:993! "work friends"
%friends/university:myname/clear@imap.gmail.com:993! "university friends"
%friends/college:myname/clear@imap.gmail.com:993! "old friends"
%friends/highschool:myname/clear@imap.gmail.com:993! "very old friends"
}
}
#Note: usernames with "strange" characters (like "@") must be written
#like: "myname@company.com". Folders at my work are delimited by dot '.'.
WORK{
%INBOX:"myname@company.com"/clear@mail.company.com "Inbox"
%INBOX.Sent:"myname@company.com"/clear@mail.company.com "Sent"
%INBOX.Drafts:"myname@company.com"/clear@mail.company.com "Draft"
%INBOX.Trash:"myname@company.com"/clear@mail.company.com "Trash"
Projects{
%INBOX.Project1:"myname@company.com"/clear@mail.company.com "Project 1"
%INBOX.Project2:"myname@company.com"/clear@mail.company.com "Project 2"
}
}
With the following setup, wanderlust will automatically send from the right email-account when you reply to a message. If you start a new draft, you can cycle through the list in wl-template-alist with C-c C-j. Sent messages from gmail account or work account ends up in the right folder.
TODO: This does NOT set the correct Draft folder!
It is not possible to change the draft folder using the mechanism below, unfortunately.
With the modified code below (non-header conses moved from wl-template-alist to wl-draft-config-alist), wl-draft-folder is properly set inside the draft buffer, but the draft is still not saved to the proper draft folder.
~/.wl
;; You should set this variable if you use multiple e-mail addresses.
(setq wl-user-mail-address-list (quote ("myname@gmail.com" "myname@company.com")))
;; How messages with disposal mark ("d") are to be handled.
;; remove = instant removal (same as "D"), thrash = move to wl-trash-folder
;; string = move to string.
(setq wl-dispose-folder-alist
'(("^%.*company\\.com" . "%INBOX.Trash:\"myname@company.com\"/clear@mail.company.com")
("^%.*gmail\\.com" . "%[Gmail]/Trash:myname/clear@imap.gmail.com:993!")
))
;; select correct email address when we _start_ writing a draft.
(add-hook 'wl-mail-setup-hook 'wl-draft-config-exec)
;; don't apply the templates when sending the draft otherwise
;; choosing another template with C-c C-j won't have any effect
(remove-hook 'wl-draft-send-hook 'wl-draft-config-exec)
;;is run when wl-draft-send-and-exit or wl-draft-send is invoked:
;;(NOTE: "M-: wl-draft-parent-folder" => %INBOX:myname/clear@imap.gmail.com:993)
(setq wl-draft-config-alist
'(((string-match "company.com" wl-draft-parent-folder)
(template . "work")
(wl-smtp-posting-user . "myname@company.com")
(wl-smtp-posting-server . "mail.company.com")
(wl-local-domain . "mail.company.com")
(wl-draft-folder . "%[Gmail]/Draft:myname/clear@imap.gmail.com:993!")
("Fcc" . "%INBOX.Sent:\"myname@company.com\"/clear@mail.company.com")
(wl-draft-folder . "%INBOX.Drafts:\"myname@company.com\"/clear@mail.company.com"))
((string-match "gmail.com" wl-draft-parent-folder)
(template . "gmail")
(wl-smtp-posting-user . "myname")
(wl-smtp-posting-server . "smtp.gmail.com")
(wl-smtp-authenticate-type ."plain")
(wl-smtp-connection-type . 'starttls)
(wl-smtp-posting-port . 587)
(wl-local-domain . "gmail.com")
(wl-message-id-domain . "smtp.gmail.com"))))
;;choose template with C-c C-j
(setq wl-template-alist
'(("gmail"
(wl-from . "My Name <myname@gmail.com>")
("From" . wl-from))
("work"
(wl-from . "My Name <myname@company.com>")
("From" . wl-from))))
;; Use different signature files based on From: address
(setq signature-file-alist
`((("From" . "myname@company.com") . ,(expand-file-name "~/.emacs.d/signature.d/myname@company.com"))
(("From" . "myname@gmail.com") . ,(expand-file-name "~/.emacs.d/signature.d/myname@gmail.com"))))
;;Cycle through templates with arrow keys
(define-key wl-template-mode-map (kbd "<right>") 'wl-template-next)
(define-key wl-template-mode-map (kbd "<left>") 'wl-template-prev)
;;default folder name auto completion:
(setq wl-default-spec "%")
;; mark sent messages (folder carbon copy) as read.
(setq wl-fcc-force-as-read t)
;;Only save draft when I tell it to! (C-x C-s or C-c C-s):
;;(arg: seconds of idle time untill auto-save).
(setq wl-auto-save-drafts-interval nil)
Wanderlust