Gmail emacs

Gmail emacs DEFAULT



Now put the following in your file, replacing <EMAIL_ADDRESS> and <FULL NAME> by your, uhm, email address and full name:

(setq user-mail-address "<EMAIL_ADDRESS>" user-full-name "<FULL NAME>") (setq gnus-select-method '(nnimap "gmail" (nnimap-address "") (nnimap-server-port "imaps") (nnimap-stream ssl))) (setq smtpmail-smtp-server "" smtpmail-smtp-service 587 gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")

Put the following in your file or better yet, in which will be automatically encrypted with GnuPG (see GnusAuthinfo and GnusEncryptedAuthInfo, as well as the ‘auth’ info node in emacs using ), replacing <USER> with your email address and replacing <APP-PASSWORD> with your application-specific password

machine login <USER> password <APP-PASSWORD> port imaps machine login <USER> password <APP-PASSWORD> port 587

NOTE: As of now, it is required that you enable 2 step authentication and then create an application specific password this is a 16 digit code that will allow gnus to connect to your account:

When sending your first email from gnus, you might get a error. If you’re using homebrew in Mac OS X, you can install the necessary package with .

You can find more information in the following sections.

Run 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 can do through the web interface.


Accessing Gmail via IMAP

Firstly, don’t forget to enable IMAP in your Gmail account (settings->forwarding POP/IMAP). Then configure and as shown above.

Alternatively, you can configure Gmail IMAP as a secondary select method for Gnus:

(add-to-list 'gnus-secondary-select-methods '(nnimap "gmail" (nnimap-address "") (nnimap-server-port "imaps") (nnimap-stream ssl) (nnmail-expiry-target "nnimap+gmail:[Gmail]/Trash") (nnmail-expiry-wait immediate))) (setq smtpmail-smtp-server "" smtpmail-smtp-service 587 gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")

Alternatively, if your email is not, you can use,, and use 465 instead of 587.

Accessing the [Gmail] folders

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:

(setq gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")

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:

(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.

Accessing Gmail via POP

Note(This needs an update to account for the fact that you now need 2 step authentication)

“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"":port 995 :user"[email protected]":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 the user name must include – 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.)

  1. Configure your Gmail account for POP support. This is under Settings in the gmail web interface.
  2. Use CVS Emacs and CVS Gnus. It won’t work any other way.
  3. Replace your installation’s “pop3.el” and “pop3.elc” with those linked to from this page:
  4. Configure as on the linked page.

– 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?

Accessing Gmail via an external mail retriever

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 with proto POP3 and options no dns user '[email protected]' 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

How to use offlineimap and the dovecot mail server


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 = remoteuser = [email protected] 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.

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 "[email protected]") (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).

Sending mail through Gmail's SMTP server

See the section with the IMAP configuration for the required settings to configure SMTP.

Storing sent mail in the server

Mails will automatically be stored in the proper “[Gmail]/Sent Mail” folder if you configured Gnus to send mail using Gmail’s SMTP server as detailed in the IMAP configuration section.


Archiving mails

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 .

Deleting mails

How can you delete a mail in Gnus so that it disappears from your Inbox in Gmail and goes to Trash?

does . 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. The Gmail server automatically purges the emails which have been in the “Trash” folder for more than 30 days.

If you do not want to wait for the 30 days and want to immediately delete a message, it must first be moved to the Trash folder (or be in the Spam folder). Then, after opening the Trash or Spam folder, you can delete the message using (). Using the function from any other folder than Trash or Spam will strip the message of that label rather than deleting the message permanently.

See the next section (Expiring mails) for a more powerful way to delete emails.

Expiring mails

The Gnus way to delete mails would be to expire them. By default, a mail marked as expired gets hidden from the view (it is considered read) for 7 days before being deleted. With the way the delete action is implemented in Gmail, this means that after 7 days, the expired messages are archived and kept forever. If, like me, the idea of leaving all your trash accumulating in your backyard doesn’t sound too appealing, the following options can be useful:

  1. nnmail-expiry-target: To tell the expiry process where to move the expired messages to. I set this to Gmail’s trash, such as: .
  2. nnmail-expiry-wait: This can be used to configure how long you’d like the expired messages to stick around. Since Gmail is already keeping the messages moved to its trash folder for 30 days, I set this to immediate:

If you copied your basic configuration from the Configuration section, it should already be configured that way for you.

Catching up

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?

does 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.

Only (or ) 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 .

Conversations view

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 “” and “[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

*Article* extracts/previews in *Summary*

Is it possible to show the first non-reply line of the article within , in order to get a “preview”?


How can you assign and remove tags from messages?

and , respectively.

Empty spam folder

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?

Not as of two years ago, according to Lars, or a few months ago either.

E-mail search

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:

(require 'nnir)

Then add the following line to the secondary-method in .gnus.el

(nnir-search-engine imap)

It should look like this:

(add-to-list 'gnus-secondary-select-methods '(nnimap "gmail" (nnimap-stream ssl) (nnimap-address "") (nnimap-server-port 993) (nnir-search-engine imap)))

Restart Gnus. With in the Groups buffer, you search for mails in the current group. Note that this will not work in virtual groups. If you want to search on all your mails, you should add the folder ‘All Mail’.

Add the following to .gnus.el to enable the same search syntax that Gmail supports:

(add-to-list 'nnir-imap-search-arguments '("gmail" . "X-GM-RAW")) (setq nnir-imap-default-search-key "gmail")

This is especially useful for restricting search to particular dates (e.g. “before:2016/11/1”, “after:2016/11/5”), finding attachments (e.g. “has:attachment”, “filename:pdf”), matching messages without a term (e.g. “-foo”), or with a particular state (e.g. “is:starred”, “is:important”, “is:unread”).

Contact autocompletion

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!

Reply-to with the same address as it was sent to

You can emulate this Gmail feature with the variable , 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 protected]") (address "[email protected]")) ((header "to""[email protected]") (address "[email protected]")) ((header "cc""[email protected]") (address "[email protected]")) ((header "cc""[email protected]") (address "[email protected]"))))

See the info node on that variable, you could easily automatically add this from a list.


Gmail used to provide an interface to their chat service using XMPP, but such support was dropped somewhere around 2013.

How do actions sync in IMAP?

From Gmail Help

Action on clientResult in Gmail on the webCommand 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 to nonexistent folder will create it.
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




Most of what I need can be accomplished through Gnus' notion of group parameters. You can theoretically customize parameters through the Customize buffer, but I abhor that awful abomination and would prefer to do it through Lisp. Fortunately, you can set most group parameters via the gnus-parameters variable. This variable is a list of alists, each of which contains a regular expression matching a group name followed by a set of parameters for that group. Below is my gnus-parameters.

‘Account customization in .gnus'

(setq gnus-parameters '(("nnimap work:INBOX" (display . all) (posting-style (name "Deon Garrett") (address "[email protected]") (organization "My Employer") (signature-file "~/.signature-work")) (expiry-target . delete) ("nnimap work:[Gmail]/.*" (display . all) (posting-style (name "Deon Garrett") (address "[email protected]") (organization "My Employer") (signature-file "~/.signature-work")) (expiry-wait . never)) ("nnimap home:(INBOX|lists..*)" (display . all) (posting-style (name "Deon Garrett") (address "[email protected]") (signature-file "~/.signature-home")) (expiry-target . delete) ("nnimap home:[Gmail]/.*" (display . all) (posting-style (name "Deon Garrett") (address "[email protected]") (signature-file "~/.signature-home")) (expiry-wait . never))))

There's a lot going on here, but basically, I have two accounts “home” and “work”, and for each account, I have one set of parameters for normal mailboxes, and another set for those “special” gmail mailboxes that I want to treat slightly differently (mainly with respect to expiry). Note the regular expressions for the group names: “nnimap XXXX:YYYY” where XXXX is the account name (“home” or “work”) and YYYY must match only the mailboxes I want. So the first block matches only the INBOX on my work account. It sets the headers I want on outgoing mail, tells Gnus to always show all messages when I enter the group, sends the correct switch to the msmtp program to select my work account (Edit: msmtp supports automatically choosing an account based on the From header. See my updated example .msmtprc file),and sets up expiry to immediate move expired messages to the “[GMail]/All Mail” folder. *Correction: I've since changed the expiry to delete the message instead of moving it to All Mail, as Gmail always keeps a copy in All Mail anyway. I have left the “expiry . never” for the Gmail groups to prevent deletion of messages from inside the Google special groups. **The second block is still the work account, but now matches only mailboxes named like “[GMail]/”, that is, all the special Gmail boxes. The only different setting here is that I tell Gnus to never expire a message from a special folder. The remaining two blocks of settings configure my home account in a similar fashion. There are a few global settings we need to set as well. We need to tell Gnus to use msmtp as our sendmail replacement. I also want all my subscribed groups to be always visible, and the “visible” group parameter won't work from gnus-parameters, so per the documentation, we need to set that in an alternate fashion. You should also set up a default set of outgoing headers so that if you send mail from outside any group, you'll still have some useful default. Below is the elisp to set up msmtp and make the groups visible. I'll leave it to you to set most of those other variables, as they're standard Gnus settings that you probably already know.

‘SMTP setup in .gnus'

(setq message-send-mail-function 'message-send-mail-with-sendmail) (setq sendmail-program "/usr/local/bin/msmtp") (setq gnus-permanently-visible-groups ".*")
  1. Persuasive writing for kindergarten
  2. Bogs neo classic vs classic
  3. Arhaus used furniture for sale

How to set up Gnus in Emacs for GMAIL in a seven easy steps (and 7 minutes!)

Write Gmail in Emacs the Easy Way: gmail-message-mode

09 Aug 2014, by Artur Malabarba.

Trying out the myriad of Emacs mail clients is no less than an odyssey. I am proud to say I dove into this sea of protocols and credentials and emerged from it a better man, albeit empty handed.

I do not blame the clients available. Gnus and Mew, in particular, are both Herculean beasts of coding prowess. It was I who failed, regrettably, to fit them into my workflow. Thus I designed my own solution.

gmail-message-mode combines all the features of Gmail's web interface, with the editing prowess we all love about Emacs. How does it work?

  • First of all, it is not a mail client.
  • In you browser, when composing a message, you invoke a hotkey that sends you to Emacs.
  • In Emacs, you can use plain text or the full power of Markdown to write your email.
  • Hit to finish your edits and seamlessly converts the message back to Gmail's format (html).

The installation process is as follows.

Install the mode

Good old will do. If you'd like to install manually, see the Readme.

Install a Markdown converter

You need an executable so that Emacs can convert the Markdown to HTML. I personally recommend Pandoc. Many distros also have a package.

If you choose something else, see the variable.

comments powered by DisqusSours:

Emacs gmail

A Complete Guide to Email in Emacs using Mu and Mu4e

I get a lot of email. I'm also pretty sure you get a lot of email. However, email is still not a solved problem. Each potential email client is acceptable on it's own, yet none of them satisfied all of my desired features:

This is evidenced by the fact that a quick Google search yields no less than ten viable options for email clients on my Mac.

  • The ability to access my email without an internet connection.
  • I travel quite a lot, so this was very important to me.

  • Easily move messages between different folders, which is how I keep all of my emails organized by project.
  • Quick yet powerful search of all my mail messages.
  • Having an auto-updating status indicator that shows me how many unread messages I have.
  • Managing multiple accounts (Gmail for personal emails and Microsoft Exchange for work emails) and syncing local changes so that my phone can still be up-to-date.

If you follow this blog, you'll recognize that I've gotten a bit carried away with migrating the different aspects of my life to operate within the Emacs environment. So it was only a matter of time until I finally decided to give it a shot, and I converged upon a solution which happily satisfies all of the above constraints. Every email service is a bit different so YMMV, but this setup works for me.

Here's a screenshot of what we'll be setting up:

My brief adventure with Gnus

There are a ton of tutorials available for reading one's email with Gnus, so it was a natural starting point for my quest. After setting it up, Gnus starts into the standard group summary list, which will display all of the folders it discovered in your various mail accounts. To me, this seemed a bit much, since I have a ton of folders, but this alone wasn't enough to deter me. Unfortunately, I also found that it was quite slow and that the interface was rather cumbersome. The suggested solution to this problem is to host a local email server (groan), which syncs with the Gmail and your other email accounts.

In fact, the slowness of Gnus is rather well documented on the Emacs Wiki

In order to get Gnus working properly, Sacha Chua recommends installing two tools: for the email synchronization and for hosting a local IMAP server, since that's how Gnus is able to read the messages. I was able to get working relatively quickly (more on that later), and before too long I had a local copy of all my emails since the dawn of time. By contrast, had me scratching my head. Not only could I not get it to work, but it seemed like an unnecessary amount of complexity; I was hosting a local webserver so that my Emacs mail client could read emails that were already saved to my system. So it was at this point that I moved on in search of a better way.

An introduction to mu

After a bit of searching around, I came across a fantastic tool called mu. At it's core, mu is a simple command line tool for searching through emails. Simply type into the terminal to query your emails.

See the mu "cheatsheet" for examples of more powerful search features within mu.

It's a cute little tool, and is especially nice for allowing you to quickly check for any new email without leaving the terminal. Yet this still doesn't solve all my problems; sure I have an offline copy of my messages and I can search them with ease, but how do I read them, move them around, or interact with them in other ways?

You can easily search for unread emails with .

This is where mu4e comes in, the Emacs email client included with mu. It's this that provides me with all of the functionality that I desire: being able to search an offline copy of my emails, easily move them around, and send/reply to different mail servers.

In addition, mu4e has the ability to auto-complete email addresses from names, follow rules about where to archive mail that matches certain filters (like keywords in the subject line) and, via an Emacs package, display a status icon in the modeline when I have new mail messages. In the next few sections, I'll describe how I got everything to work, and any pitfalls I encountered along the way.

Getting set up with mu and OfflineIMAP

As advertised, mu is really just for indexing and searching emails, and relies on other software to maintain a local copy of your messages, which it can then use. To do this, I chose to use the popular OfflineIMAP, since it's relatively easy to get setup. I have my OfflineIMAP manage two different accounts, Gmail and Exchange, and sync changes between the online services every 5 minutes. Rather than ramble on about how everything should be set up, I'll just reproduce some of the important parts of my configuration file here (taken from my ):

On macOS, I installed this with ; on Ubuntu, this can be done with apt.

And example OfflineIMAP configuration

You'll notice a few things about this configuration. First, as I have it listed above, you have to enter your password directly into this file, which you probably don't want to do; there's a great Stack Exchange post on how to use GPG and python to encrypt your password. Second, I have included a to avoid storing the All Mail and Important folders that Gmail annoyingly creates. Finally, I call whenever the sync is complete, via , to ensure that my mu database is as up-to-date as much as possible.

You may also notice that arbitrary python code can be specified as part of the configuration.

By default, mu looks to for mail, but I like to include it for clarity.

Once this is setup, calling from the command line will sync with the remote repositories every 5 minutes. However, this requires keeping the terminal window open. This can be solved by creating a daemon process. On macOS, this is built in to brew, and calling will get everything started; for Linux, you can follow these instructions on the Arch Linux wiki.

With this step complete, the command line version of mu should now be syncing with the remote server(s) without any issues.

Configuring mu4e

Before even getting to the Emacs configuration file, you should ensure that mu4e is properly installed. Since mu4e is included with the installation of mu you need to include mu4e. This can be done with something like . Now, upon reopening Emacs, should open a simple window with some shortcuts. Typing will bring up a menu for selecting a mail folder. Chose one, and you should be presented with something resembling the screenshot above.

On macOS, this is only partially true. See to insure that the install includes mu4e.

When in the headers view, which displays your email messages, you can easily navigate through different messages using and and hitting will open a message, allowing you to read it. In addition, mu4e includes some very useful marking capabilities: marks a message for deletion, for refiling/archiving, and for moving (after a target directory is specified). Simply press to "execute" the marks. In addition, with you can "bulk mark" emails; pressing after some messages have been marked with will allow you to perform an action to all of them. See the mu4e user manual for more details.

I mentioned above that I have two different email addresses and rely on mu4e to manage them both. In the previous screenshot, you can see that I've marked messages for archiving with and deletion with yet the behavior for the different messages changes depending on their mu4e context. By setting the variable, mu4e will search through the list of options, see if the message of interest matches and sets some local variables, like the . In the snippet below, I check to see if the mail directory () includes and, if it does, sets the trash and refile folders accordingly.

See the section below for a caveat about deletion, to avoid premeturely deleting your messages!

Defining mu4e contexts

For my Exchange server, I have a slightly more complicated procedure; rather than including a specific refile folder, I define a function which does some more filtering. Apparently I don't want any emails from this fictitious going to the typical archive folder. So, whenever I get a message which includes "[some-mailing-list]" in the subject, I can still refile the message with and know that it will go to the correct folder.

A custom refiling function

Alerts for new mail

Now that we can receive email, move it around and keep everything in sync with our different IMAP servers, the next task is to ensure that we're alerted whenever new mail arrives. Fortunately, there's another Emacs package for doing just this: mu4e-alert. The procedure for using mu4e-alert is relatively simple. Whenever you call , your modeline will be updated to include a little envelope icon and the current count of unread messages.

The format of the modeline display can be changed by customizing .

You're expectedly a bit annoyed, thinking I thought the icon would update itself! Fortunately, Emacs has the for just this purpose. However, there remains a small issue: whenever mu4e is open, it maintains a connection to the server. This means that cannot be run by the OfflineIMAP process whenever mu4e is left open, and new mail will not appear. This is far from ideal. Again, I have a slightly hacky solution. By calling periodically, we can sever mu4e's connection to the server. The only consequence of this is that I may occasionally try to archive messages in my inbox that I've already moved on my phone, an issue which is easily remedied by refreshing my mu4e buffer.

My complete mu4e-alert configuration, which relies on John Wiegley's use-package, is as follows:

Mu4e-alert configuration

There's one other hiccup that I haven't yet mentioned; some email servers (cough Gmail cough) will mark messages as unread whenever they are moved to other folders, including the trash. As a result, I've customized my variable to check for unread messages in only my inbox folders.

Using mu4e to send mail

Unfortunately IMAP, the protocol for checking email and moving them around, cannot be used to send emails: for that you need to configure SMTP. This process isn't particularly difficult, but it does include a bunch of code, most of which is adapted from the mu4e documentation. After setting the default values for many of the SMTP parameters, we create a list of account-specific parameter values which are loaded upon composing a message by the function. I've included most of my configuration here for the sake of completeness.

If you only have a single account, most of this is unnecessary.

Configuration for sending mail

Pitfalls and additional tweaks

I already touched upon a few of the minor issues I encountered when getting everything here to work properly, including how moved messages will occasionally be marked as unread. The biggest uh oh I had to deal with stemmed from some unexptected behavior with OfflineIMAP. Apparently, whenever a message is marked with the trash label , which happens whenever you 'delete' a message with , OfflineIMAP won't sync it back to the server and, worse still, may delete it entirely. Even though I've marked an item for deletion, I'm comforted by the fact that I can recover a message if I accidentally move it to the trash.

Avoiding this issue requires modifying the way the delete mark operates. I simply replaced with in the definition of the trash mark. It was a simple (if rather verbose) fix, so I've included it here in its entirety.

Avoid trashing when deleting

Finally, here are a few more tweaks to the mu4e settings that I frequently use.

Other tweaks

Wrapping Up

I'll try to keep this document up-to-date as I experiment more, however I'm already quite happy with my setup after a couple of weeks of trying it out. There are plenty of features that I haven't touched upon as well, including the ability to link to email messages via org-mode, in which I do much of my work. At any rate, it's just another excuse for me to never leave my Emacs environment.

Using Emacs Episode 64 - notmuch


(require'offlineimap)(add-to-list'load-path"~/.emacs.d/lib/mu4e")(require'mu4e)(require'mu4e-maildirs-extension)(mu4e-maildirs-extension)(setq mu4e-drafts-folder "/drafts" mu4e-sent-folder "/sent" mu4e-trash-folder "/trash")(setq mu4e-maildir-shortcuts '(("/INBOX".?i) ("/sent".?s) ("/trash".?t) ("/drafts".?d) ("/review".?r) ("/cours".?c) ("/private".?p) ("/inserm".?m) ("/aphp".?a) ("/mailing".?l)))(add-to-list'mu4e-bookmarks '("flag:attach""Messages with attachment"?a) t)(add-to-list'mu4e-bookmarks '("size:5M..500M""Big messages"?b) t)(add-to-list'mu4e-bookmarks '("flag:flagged""Flagged messages"?f) t)(setq mu4e-headers-date-format "%Y-%m-%d %H:%M:%S" mu4e-headers-fields '((:date.20) (:flags.5) (:mailing-list.10) (:from-or-to.25) (:subject.nil))) (setq mu4e-reply-to-address "xxxxxxxxxx" user-mail-address "xxxxxxxxxx" user-full-name "xxxxxxxxxx" message-signature "xxxxxxxxxx" message-citation-line-format "On %Y-%m-%d %H:%M:%S, %f wrote:" message-citation-line-function 'message-insert-formatted-citation-line mu4e-headers-results-limit 250)(require'smtpmail)(setq message-send-mail-function 'smtpmail-send-it starttls-use-gnutls t smtpmail-starttls-credentials '((""587nilnil)) smtpmail-auth-credentials (expand-file-name"~/.authinfo.gpg") smtpmail-default-smtp-server "" smtpmail-smtp-server "" smtpmail-smtp-service 587 smtpmail-debug-info t)(setq message-kill-buffer-on-exit t mu4e-sent-messages-behavior 'delete mu4e-headers-skip-duplicates t mu4e-headers-include-related t mail-user-agent 'mu4e-user-agent mu4e-get-mail-command "offlineimap" mu4e-attachment-dir "~/Downloads" smtpmail-queue-mail nil smtpmail-queue-dir "~/Maildir/queue/cur")

Similar news:

The girls sat down on their knees opposite each other and began kissing passionately. Ieliot hugged her friend around the waist, and she hugged her neck. Then, Ieliot unwound her belt and tossed it aside, while Isolian was already pulling off her dress.

2277 2278 2279 2280 2281