요약: Added work-around for adaptive score bug of [Gmail] folders.
> ====Adaptive Scoring in the [Gmail] folders====
> There is a bug in Gnus v5.13 that prevent adaptive scoring to be used in [Gmail] folders. The ADAPT files are created and updated, but scores are not adjusted.
> If you want to use adaptive scores in these folders, a simple work-around is to define nnheader-file-name-translation-alist as follows:
> ;; Replace [ and ] with _ in ADAPT file names
> (setq nnheader-file-name-translation-alist '((?[ . ?_) (?] . ?_)) )
> Note that this will not rename ADAPT files in your News directory. You need to either rename existing files or delete them.
Put the following in your
~/.gnus file and replace “email@example.com” with your email address:
(setq gnus-select-method '(nnimap "gmail" (nnimap-address "imap.gmail.com") (nnimap-server-port 993) (nnimap-stream ssl))) (setq message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)) smtpmail-auth-credentials '(("smtp.gmail.com" 587 "firstname.lastname@example.org" nil)) smtpmail-default-smtp-server "smtp.gmail.com" smtpmail-smtp-server "smtp.gmail.com" smtpmail-smtp-service 587 gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")
Put the following in your
~/.authinfo file and replace “email@example.com” with your email addres and replace “secret” with your password—or your application-specific password:
machine imap.gmail.com login firstname.lastname@example.org password secret port 993 machine smtp.gmail.com login email@example.com password secret port 587
You can find more information in the following sections.
‘M-x gnus’ and enjoy.
Gnus can connect to the gmail server in two ways: by POP3, or by IMAP. Each protocol behaves in a different way, so you can select the one which better suits your needs. Furthermore, as a third solution you can download your mail with an external program like fetchmail and let Gnus handle it locally.
This page describes how to configure Gnus to read and send mails from your gmail account, and should also explain how to do in Gnus what you’re able to do through the web interface.
Firstly, don’t forget to enable IMAP in your Gmail account (settings->forwarding POP/IMAP). Settings to tell gnus to use Gmail’s IMAP as a (secondary) select method are as follows:
(add-to-list 'gnus-secondary-select-methods '(nnimap "gmail" (nnimap-address "imap.gmail.com") ; it could also be imap.googlemail.com if that's your server. (nnimap-server-port 993) (nnimap-stream ssl)))
with a line like the following one in your ~/.authinfo
machine imap.gmail.com login firstname.lastname@example.org password secret port 993
If you prefer enable Gmail as primary select method (if you choose this, there is no need to put the previous section in ~/.gnus):
(setq gnus-select-method '(nnimap "gmail" (nnimap-address "imap.gmail.com") ; it could also be imap.googlemail.com if that's your server. (nnimap-server-port 993) (nnimap-stream ssl)))
Also, if you want to take advantage of using gmail’s SMTP server (so gmail keeps track of your sent mail), you can use the following settings:
(setq message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)) smtpmail-auth-credentials '(("smtp.gmail.com" 587 "email@example.com" nil)) smtpmail-default-smtp-server "smtp.gmail.com" smtpmail-smtp-server "smtp.gmail.com" smtpmail-smtp-service 587 smtpmail-local-domain "yourcompany.com")
Alternatively, it could be googlemail on the port 465, notably if you have an email not @gmail.com:
(setq message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials '(("smtp.googlemail.com" 465 nil nil)) smtpmail-auth-credentials '(("smtp.googlemail.com" 465 "firstname.lastname@example.org" nil)) smtpmail-default-smtp-server "smtp.googlemail.com" smtpmail-smtp-server "smtp.googlemail.com" smtpmail-smtp-service 465 smtpmail-local-domain "yourcompany.com")
NOTE: You will need starttls, which is used to set up the SSL encrypted connection to the GMail server. This is contained in the “gnutls-bin” package on earlier versions of debian and ubuntu. With later versions (at least Ubuntu 9.10), starttls is in its own package, and the “gnutls-bin” package is not needed. If you don’t have starttls installed, you’ll get a (rather generic) “smtpmail-send-it: Sending failed; SMTP protocol error” error message.
NOTE: (Pointed out by ChristofHarper) You can also store your password in the smtpmail-auth-credentials line, but this means that you’ve got to be more careful when sharing config files with other people.
NOTE: It seems that the above settings (which are what Google recommends) don’t work for some people. Another possibility is to use port 25, and then use ~/.authinfo to convert it back to 587, thus circumventing some code which was getting confused about SMTP through a non-25 port. To do this, replace all occurrences of 587 with 25 in the above snippet, and add the following line to your ~/.authinfo (see GnusAuthinfo and GnusEncryptedAuthInfo):
machine smtp.gmail.com login email@example.com password secret port 587
machine smtp.googlemail.com login firstname.lastname@example.org password secret port 465
If you don’t wish to store your password there, just omit the “password secret” altogether and you’ll be prompted when you send an email.
NOTE for MS Windows users: Recent emacs or gnutls-cli may choke. Possible remedy is explained here. This is confirmed to work on Emacs 18.104.22.168 from bazaar built with gcc 4.6.2 on Windows XP SP 3. The following is the exact command added
(setq tls-program '("C:/PROGRA~1/Git/bin/openssl.exe s_client -connect %h:%p -no_ssl2 -ign_eof"))
All Gmail system labels have a prefix [Gmail], which matches the default value of gnus-ignored-newsgroups. A workaround is to redefine it as follows:
;; Make Gnus NOT ignore [Gmail] mailboxes (setq gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")
There is a bug in Gnus v5.13 that prevent adaptive scoring to be used in [Gmail] folders. The ADAPT files are created and updated, but scores are not adjusted.
If you want to use adaptive scores in these folders, a simple work-around is to define nnheader-file-name-translation-alist as follows:
;; Replace [ and ] with _ in ADAPT file names (setq nnheader-file-name-translation-alist '((?[ . ?_) (?] . ?_)) )
Note that this will not rename ADAPT files in your News directory. You need to either rename existing files or delete them.
“Retrieving mail with POP3 is supported over SSL/TLS and with StartTLS.” (from GNUS-NEWS)
Put the following in your gnus-init-file is sufficient.
(setq mail-sources '((pop :server "pop.gmail.com" :port 995 :user "Leo@gmail.com" :password "wrongpw" :stream ssl)))
I have tested this with No Gnus 0.6 (2006-10-19) and XftGnuEmacs (2006-10-04).
In case you want to use gnus only as a pop-mail reader, you need to add the following line before adding mail sources:
(setq gnus-select-method '(nnml ""))
According to http://mail.google.com/support/bin/answer.py?answer=13287 the user name must include @gmail.com – AdrianAichner
There is bleeding edge support for sending/getting email through Gmail using only Gnus (and not the webmail interface.) I’ve verified that this works (rather well in fact.)
– NOTE: you also need ssl.el, which doesn’t seem to come with the current GNU CVS. I found it with a quick google search.
– I still can seem to get any messages from the server. I’ve solved the problems with connection and missing load files, but now it will connect and not report any of the messages. Any hints?
Note that you can also get your mail from Gmail using fetchmail if that’s installed on your home system. The following .fetchmailrc works for me:
poll pop.gmail.com with proto POP3 and options no dns user 'USERNAME@gmail.com' there with password 'PASSWORD' is 'LOCALUSERNAME' here options ssl
You can then set up a cron job to run fetchmail every few minutes:
*/3 * * * * fetchmail -s >/dev/null 2>&1
– ALTERNATE: Instead of using cron, you could always add “set daemon 300” (without the quotes) to your .fetchmailrc to use its built-in daemonic capabilities. The “300” tells it to run every 300 seconds (five minutes). Change this number to suit your tastes.
and let gnus read your mail from wherever the usual location is on your system.
Another possibility: if you set up a Gmail filter by entering “in:inbox” in the “Has the words” field (you will get an error message but ignore it) you can have Gmail forward all your mail from your inbox (leaving spam behind) to some location where you can access it without changing your emacs or gnus installation.
Not even the above is necessary (as of 2006-12-02), gmail has now an option for forwarding the whole inbox to another address. dida
Make sure you’ve set up Postfix or some other mail server that can send mail. I’m not going to cover that because my configuration for outgoing mail doesn’t use Gmail.
Install dovecot (IMAP server) and offlineimap (IMAP synchronization). You can probably find binaries for your distribution.
Edit /etc/dovecot.conf and set the following:
default_mail_env = maildir:%h/Maildir
Put the following in ~/.offlineimaprc, changing your_local_username, your_username, and your_gmail_password:
[general] accounts = Gmail maxsyncaccounts = 1
[Account Gmail] localrepository = Local remoterepository = Remote
[Repository Local] type = IMAP remotehost = localhost port = 143 remoteuser = your_local_username
[Repository Remote] type = IMAP remotehost = imap.gmail.com remoteuser = email@example.com remotepass = your_gmail_password ssl = yes maxconnections = 1 realdelete = no folderfilter = lambda foldername: foldername in ['INBOX']
If you feel comfortable specifying your password for your local account in your ~/.offlineimaprc, you can do so by adding a remotepass line under the remoteuser line in the [Repository Local] section.
chmod go-rwx ~/.offlineimaprc for a little bit of safety.
Type offlineimap to start synchronizing.
While that’s synchronizing, use something like this as your ~/.gnus:
(setq gnus-select-method '(nnimap "Mail" (nnimap-address "localhost") (nnimap-stream network) (nnimap-authenticator login)))
(setq user-mail-address "firstname.lastname@example.org") (setq gnus-ignored-from-addresses "youruser")
Start Emacs. Start Gnus with M-x gnus. If you don’t see the INBOX group, press ^ (gnus-group-enter-server-mode), open nnimap:Mail, move your cursor to the INBOX, and either press RET to go into the group or press u (gnus-browse-unsubscribe-current-group) to toggle the subscription status until you’re subscribed to the group. Then it should show up on the group screen (M-x gnus).
See the section with the IMAP configuration for the required settings to configure SMTP.
By default, the mail you send from Gnus is not copied to the Gmail server, so if you open the folder “Sent mail”, you won’t see it. You will only see mail sent from the web interface.
TODO: how to store sent mail in the server? (See below.)
A workaround can be CCing yourself whenever you send a mail. With this approach you’ll get a copy which is reflected on the server as well. Moreover, you’ll be the sender of these copies which makes it easy to define a view including only these messages. To use this solution, write this into your .gnus.el file:
(setq gnus-posting-styles '((".*" ("CC" "email@example.com") (address "firstname.lastname@example.org"))))
Actually, the problem seems to be solved if you send mail via gmail’s smtp server - at their “Recommended IMAP client settings” they say:
“Do NOT save sent messages on the server. If your client is sending mail through Gmail’s SMTP server, your sent messages will be automatically copied to the [Gmail]/Sent Mail folder.”
What is the equivalent Gnus command to the „Archive“ button? (Remove from „Inbox“ and stay in „All mail“)
Remove the “Inbox” tag by deleting from the “INBOX” folder with
How can you delete a mail in Gnus so that it disappears from your Inbox in gmail and goes to Trash?
B m does
gnus-summary-move-article. Invoke it, then type “[Gmail]/Trash”. In Gmail terms, this will remove the “Inbox” label and apply the “Trash” label. Messages in the trash don’t show up in other folders, even though they may have other labels.
To really delete, type
B DEL (
gnus-summary-delete-article), but beware: you’ll have to delete it from the Trash or Spam folder for it to really delete it. Otherwise, it will only remove the label from the message. I suggest writing a script (probably relying on Message-ID) to find the same message in the trash and delete that copy.
Moving an email to the trash will fail to remove the Inbox label. The solution is to make Gnus locate the message in [Gmail]/All Mail with the same Message-ID as the one in INBOX. Delete the one in the Inbox and move the one in All Mail to the trash. Crocky, but the only solution unless Gmail fixes this on their end. Anyone who has the skill to write this script is welcome to do it.
If you are seeing some mails in Gnus, and then you delete them in Gmail’s web interface, how can make them also disappear from the Gnus view?
gnus-group-get-new-news in group mode. This doesn’t seem to work completely correctly: it may report incorrect numbers of unread messages in each group after an update.
M-g) didn’t work with the normal configuration. I have seen that Gmail starts working perfectly in Gnus after you disable Gnus Agent, with (setq gnus-agent nil). It seems that gnus-agent and nnimap don’t play well together.
A less drastic solution is to only disable gnus-agent for Gmail. Go to the server buffer with
^ and disable the agent for Gmail with
How can you see in a single thread both the received message and the sent messages to a person? (As in Gmail’s web interface).
Create a nnvirtual group that contains both “nnimap+imap.gmail.com:INBOX” and “nnimap+imap.gmail.com:[Gmail]/Sent Mail”, and you can have conversational view in that group.
Then click “u” on INBOX to avoid seeing both nnvirtual:INBOX+sent and INBOX (note: don’t use “k”, then you’ll lose the read/unread/star flags; see https://www.gnu.org/software/emacs/manual/html_node/gnus/Group-Levels.html#Group-Levels).
Is it possible to show the first non-reply line of the article within
‘gnus-summary-line-format’, in order to get a “preview”?
How can you assign and remove tags from messages?
B c and
B DEL, respectively.
How can you access your spam folder and review and really delete all messages? (Not move them to Trash!)
How can you see the spam folder in the first place? Since I don’t see it in the „Gnus browse server“ buffer (accesible from key ^). It’s the only folder missing.
See the configuration section.
How can you stop composition of an e-mail and store it in Gmail’s draft folder? How can you recover it again?
In the same way as you can for any other gnus backend (composition is separate from the sending method, mostly): save the mail via C-x C-s and then exit it with C-c C-k. When you look in your nndraft:drafts folder, you’ll see it there. To edit, hit e on the mail.
nndraft is fast, but sometimes it may be convenient to store the draft in the remote folder (for mobility between computers). Any simple solution for that?
How can you search a text string through all your e-mails?
This works only for IMAP.
From Searching IMAP in Gnus. Add the following line to your .emacs:
Then add the following line to the secondary-method in .gnus.el
It should look like this:
(add-to-list 'gnus-secondary-select-methods '(nnimap "gmail" (nnimap-stream ssl) (nnimap-address "imap.gmail.com") (nnimap-server-port 993) (nnir-search-engine imap)))
Restart Gnus. With
G G in the Groups buffer, you search for mails in the current group. Note that this not work in virtual groups. If you want to search on all your mails, you should add the folder ‘All Mail’.
When you compose a message in Gmail, you type the first letters, and a list open ups with the contacts whose name matches what you wrote. How can you manage your contacts and do autocompletion in Gnus?
Using BBDB (see CategoryBbdb) you can manage your contacts, and have their names autocompleted when composing new messages.
But Gmail tracks information automatically about all e-mails ever seen, whereas in BBDB you must add each manually. Which BbdbConfiguration must be applied to act more Big-Brother-alike, like Gmail?
You can put the following in your .gnus or init.el or whatever:
(setq bbdb/news-auto-create-p t)
There is also a new project called Org-contacts which combines Org-mode (for email storage) and Gnus (for mailing). It works quite well!
You can emulate this Gmail feature with the variable
‘gnus-posting-styles’, which also allows you to set a whole bunch of other variables based on the email you reply to or the group you’re in. A very simple example, for just two addresses, would be:
(setq gnus-posting-styles '(((header "to" "email@example.com") (address "firstname.lastname@example.org")) ((header "to" "email@example.com") (address "firstname.lastname@example.org")) ((header "cc" "email@example.com") (address "firstname.lastname@example.org")) ((header "cc" "email@example.com") (address "firstname.lastname@example.org"))))
See the info node on that variable, you could easily automatically add this from a list.
Gmail provides a chat interface which uses the XMPP (Jabber) protocol; therefore you can use Emacs Jabber (see JabberEl or BitlBee) to chat with your contacts and with anyone who has a Jabber account.
From Gmail Help
|Action on client||Result in Gmail on the web||Command in Gnus|
|Open a message||Mark a message as read|
|Flag a message||Apply a star to the message|
|Unflag a message||Remove the star from the message|
|Move a message to a folder||Apply a label to the message|
|Move a message to a folder within a folder||Apply a label showing folder hierarchy (’MainFolder/SubFolder’)|
|Create a folder||Create a label|
|Move a message to [Gmail]/Spam||Report a message as spam|
|Move a message to [Gmail]/Trash||Move a message to Trash|
|Send a message||Store message in Sent Mail|
|Delete a message in inbox||Remove the message from inbox|
|Delete a message from a folder||Remove that label from the message|
|Delete a message from [Gmail]/Spam or [Gmail]/Trash||Delete the message permanently|