koldfront

Gnus email Gmail

While Gmail is just another IMAP server seen from the Gnus point of view, use of it is quite widespread, so here is a description of how to use Gmail from Gnus.

Table of contents

Reading

Gmail is added as another IMAP server to ~/.gnus, as previously shown, so I expand it like this:

; Get local email, and store it in nnml; connect via IMAP to imap.mcom.com,
; and also via IMAP to imap.gmail.com:
(setq gnus-secondary-select-methods '((nnml "")
                                      (nnimap "imap.mcom.com")
                                      (nnimap "imap.gmail.com"))

And as I don't care to enter my password all the time, I add a second line to the ~/.authinfo file:

machine imap.mcom.com login asjo@mcom.com password MyPassword port imap
machine imap.gmail.com login asjoegren@gmail.com password MyGPassword port imap

When you start Gnus after adding the new account it automatically subscribes to all the folders on your Gmail account:

Gnus Gmail

Sending

You may want to also use Gmail for sending email, rather than using local delivery of outgoing emails (saves you the trouble of configuring a mail transfer agent - such as Postfix - on your local machine).

To do that, I need to tell Gnus to do so, by adding these lines to ~/.gnus:

; Send email via Gmail:
(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-default-smtp-server "smtp.gmail.com")

The first one says to use SMTP for sending, the second what machine to talk to.

Now, Gmail wants you to authenticate when sending via SMTP, so I add a third line to the ~/.authinfo file to let Gnus know what login and password to use (rather than asking me), making the file look like this:

machine imap.mcom.com login asjo@mcom.com password MyPassword port imap
machine imap.gmail.com login asjoegren@gmail.com password MyGPassword port imap
machine smtp.gmail.com login asjoegren@gmail.com password MyGPassword

(I leave out the port on the new line, so Gnus/Emacs can choose smtp (25), submission (587), or whatever by itself.)

That's basically it.

Archiving

To store copies of your sent emails on Gmail, you simply need to adjust the generic description of how to do that with IMAP to the server and group name to use:

; Archive outgoing email in Sent folder on imap.gmail.com:
(setq gnus-message-archive-method '(nnimap "imap.gmail.com")
      gnus-message-archive-group "[Gmail]/Sent Mail")

Further reading...

Beginning of the Gnus email tutorial.

Topics to cover as time permits:

Contact

If you have any comments, ideas or corrections, don't hesitate to email me.

0.0026 s
webcustodian@koldfront.dk