 Are you an Emacs user? Are you also an email user? Would you like to be able to check your email inside of Emacs? Today I'm gonna show you how to set up the MU4E email client inside of Doom Emacs. So let me switch over to the desktop here. And today I am in a virtual machine of Arco Linux. I'm gonna be demonstrating this on an ArchBase system. And I mentioned that because we're gonna have to install a couple of different programs to make this work. And these programs we're installing, they may be named differently if you're on a non-Arch distribution. So something like Debian or Ubuntu, I don't know what exactly these package names will be. But on Arch, what we need to do is first, I need to bring up a terminal. I'm gonna zoom in so you guys can see what I'm about to install here. And we need to install using a AUR helper like EA. Because the packages that we wanted to install are actually not in the normal Arch repositories, even though they're actually pretty common programs that probably should be in the standard Arch repositories. First we need to do a yay space dash capital S space MU. We're gonna install MU, which is a email indexer and searcher. That's kind of what MU4E actually is. It's MU4emacs. I hope that makes sense. And then space, and then we also wanna install a program called mbsync dash yet. So we need both of those programs. And this may take a while to install. This is a fresh VM, so I'm actually gonna have to actually run through the installation. I know one of these actually can take some time to compile. So be prepared to wait a couple of minutes for this thing to compile. All right, and now that we have installed MU and mbsync, the next thing I need to do is I actually need to install doomemacs within this VM. Now, you guys, if you're watching this video, you probably already have doomemacs installed. But for me, let me open up a browser. And if you've never installed doomemacs, it's actually pretty easy to install. Just do a quick search for doomemacs in your web browser and go to the doomemacs GitHub. And if you scroll down just a little ways, you will have the installation instructions. It is a simple git clone. So copy the git clone and paste that line. And it clones the doomemacs repository and then run the doom install command here. And we will let that install and close the browser out. The doomemacs installation will also take a couple of minutes to build. And doomemacs has finished installing to make sure that doomemacs installed properly. Let me go ahead and launch emacs. And yeah, it looks like everything is working just fine. Now, we are gonna play with the configuration file for doomemacs, the configuration file. If you do space period to open the find file command here and navigate to dot doom.d. That's a hidden directory in your home directory, dot doom.d. And this is where your config.el, your init.el and your packages.el should live on the system. We definitely want to go down to packages.el. And let me page down here. Go to the end of the document and we want to start adding some new packages. Type the word package exclamation point space mu4e. And then write that. What this is telling doomemacs is, it's a third party package, mu4e. I want you to install it the next time we rebuild doomemacs, but we're not done yet. Other than adding package exclamation mu4e to the packages.el, we also want to go into the dot doom directory and get into config.el. And what do we need to add to the config.el? Well, the easiest thing would be for you guys to go to mygitlab. Go to gitlab.com slash dwt1 and look for my dot files repository. Go into my dot files repository, go to the dot doom.d folder and go to myconfig.el or myconfig.org. I'm going to click on config.org because it's easier to read. It's a literate config that's got a lot of comments. And if you scroll down to mu4e, there's a heading called mu4e. There it is. And what you want to do is just grab this entire block of code here, the source block and paste it into your config.el. What I'm actually going to do is I'm going to get cloned in my entire dot files repository, since these are my personal configs anyway, I'm just going to use myconfig. So I'm going to get back over here. I'm going to close out doomemax here since I'm going to use myconfigs. And I'm going to run a git clone https colon slash slash gitlab.com one period too many, maybe some input lag from the VM here. gitlab.com slash dwt1 slash dot files git. And we're just going to clone my dot files. This will take just a minute or two. That was actually pretty fast. And then what I'm going to do is I'm going to open up a graphical file manager because we're going to be creating some various files here. And I think it'll be a little easier to show you guys some of what we're going to do here. So the first thing I'm going to do is I'm going to go grab my doomd directory here from the dot files repository we just cloned. I'm just going to copy that. And then I'm going to go back into the home directory and I'm going to paste it. And I'm going to overwrite the default doomemax configs with my personal configs. Now that I've done that though, we have to rebuild doomemax. So I'm going to clear the screen here and I'm going to run this command here dotemax.d slash bin slash doom space. And then instead of install, which is the command to install doomemax, we're going to do sync, which is a rebuilding of the system based on packages.el, init.el, and our config.el. Because all three of those files have changed because I copied my configs into that directory. So it's got to rebuild. It's going to install all the plugins that I use in my configs. This may take a second. All right, doomemax finished rebuilding. So let me switch workspaces here and launch emacs again. Let's make sure my config file is actually working. It doesn't look like the theme loaded. If I, my key bindings all work though it looks like. So let me go into dot doom.d and go to my config.org. Yeah, it looks like all my plugins and everything are working because it's got icons and everything that's in my config. But for some reason, the theme did not set. So if you do what I just did and get clone my doomemax and you get this white screen, you just do space ht and this allows you to change the theme and the theme that I use, at least the theme that's listed in my config that should have loaded, but for some reason did not, is doom-1 load that. All right, and that is my proper config. It looks like one of the problems with the config is it could not locate a font mononoke nerd font. Okay, so that may have also been an issue. Maybe that's why the config was a little wonky there. So if I go to the table of contents here in myconfig.org and click on MU4E, it'll take us to that section. The VM is a little slow here because one of the fonts that's listed in my config isn't here, it's causing us some issues. But anyway, in the MU4E section, you see the source code block. It's exactly what was on my GitLab. It's the exact same thing. And all you guys probably need to do is go in here and change the settings. For example, you need to obviously change my email address to your email address, my name to your name. The other thing you should do is I have a line in here that says mbsync-c and then .config slash MU4E-dt. That's specifically for me. But if you guys want to use my configs, I want you to change this line to just .config slash MU4E, not MU4E-dt. The reason is I have my personal MU4E configs in a different directory than the ones that are listed in my .files. So change that line if you are using my config. And then what we need to do is I'm gonna go back to this workspace here, go into my .files repository once again and go into .config and then look for the MU4E folder that we just referenced and copy that. Then go back into the home directory to your proper .config directory and paste that MU4E directory. Now I created these files in this directory and put these in my .files just for purposes of this video and to help you guys get up to speed with MU4E very quickly. So let me show you the most important file here is the mbsync-rc. And I'm gonna open that in Doomy Max and I went ahead and installed the proper fonts off camera so my Doomy Max config now loads properly and now I should be able to use my functions to zoom in and let's see, can I change this to full screen here? There we go. All right, so the mbsync-rc is pretty easy to configure. You have your IMAP account and you need to name a email store. This will be a directory somewhere on your system. I just name it user-domain. It's the convention I use, so derrickdistrotube.com. I'm gonna have a folder called derrick-distrotube. Then I have my host, which I host my own email at oneandone.com, it's a very large domain registry. And then my user is of course derrick-distrotube.com. The email address is the username typically. And then the pass command is this GPG2 command because we are gonna GPG encrypt our email password. So just leave this as is. There's really nothing you guys need to change except the name of the folder, the host and the username. The rest of this, well, you also would have to go in and change all the derrick-distrotubes here because that particular directory, of course you will want to change to a different directory. And then just as an example, I set up a second account because many people of course have more than one email account and this is a fictional account. Marysu-distrotube, that will be the directory, the email store, and maybe her email address is marysu, mary-underscore-su-at-distrotube.com. Anyway, I'm just showing you how to set that up if there was a marysu-at-distrotube.com email address. So that is the mbsync. Let me close out of that. Let me pull back up my PCMan FM here. Now the other file here, mbsync-pass, you actually can't read that. Let me do a folder view and detailed list view. mbsync-pass-acc1. Now you actually need two different files. If you were doing two email addresses like I'm doing, which is derrick-distrotube.com and marysu-distrotube.com, then I also need to create a second empty file. I'm gonna call it mbsync-pass-acc2 for account two. And then these are plain text files. These are plain text files. You need to put your password in these files. So if I open this, I'll open it again and do memax here. This should just be one word. It should be your password. This is a fictional password, of course. Password 1234. Imagine that's your password. And then the same thing with mbsync account two. So if I opened mbsync-acc2, we need to insert a password for this as well. I'll do one password 1234. We'll just assume that it's the same password. And then once we have those done, what we wanna do is we wanna encrypt these files because we don't want our passwords just sitting around in a plain text file. So in your terminal, what I would do is cd into the .config slash mu4e directory and then run the following command, GPG to space-c mbsync-pass-account one. And it's gonna ask you to enter a passphrase. Enter a passphrase that would be able to unlock this GPG account. Make sure you pick something that you could remember if you need it because if you lose the passphrase, you could be in trouble. And you see over here that now we have mbsync-pass-account one. And we also have mbsync-account one.gpg because we encrypted the plain text file. Now that we've done that, delete the plain text file. We don't want that, right? Now we just have this encrypted thing that nobody can read except you because you have the passphrase. Now we also, since we had a second account, let's go ahead and encrypt the second account as well. Once again, pick a passphrase that you can remember here. All right, now that we have those, delete the account to plain text file. So you should have your mbsync-rc, which is the config file, and then the two password files that are GPG encrypted. And of course that's assuming you're using two accounts for email. If you just have one email address, then you're only gonna have the one account one.gpg. Well, let me clear the terminal here. We need to run the following command. I'm gonna run time, and the time command is just giving me the time that it takes for this to actually run. It's not really the command. The actual command is mu, because remember we installed the mu program from the AUR, and then index dash dash mail dir for mail directory equals and then the location of our mail directory, put it in your home directory at mail dir, capital M, mail dir. Then also give it this flag dash dash my dash address equals, and then in single quotes, put your email address. So I'm gonna do derrick at distrode tube.com, that period that appeared twice again. I hope you guys can see that. Let me adjust this so you can see the full command time, mu index dash dash mail dir equals the mail dir, then dash dash my dash address equals your email address. Run that command. Not that command will actually not run until we create the directories. I should have known that. So what I'm gonna do is, in the graphical file manager, since we have it open, go back to your home directory. And if you don't already have that mail dir directory, then why don't you create a new folder and call it capital M mail dir. Now what you also need to do is go into the mail dir directory and create, in my case, two other directories because remember the email stores. Now what mine are, remember in my MBR sync, there was a folder that should be called dirrick dash distrode tube. There was also the fictional second email account I was setting up for mary sue dash distrode tube. Now whatever you name your stores and your MBSync RC, then you need to create these folders with the proper names. Now that I have those names though, let me run that time mu index command once again. And I still got a failure. I think the failure is because I didn't run the mu init. Let me rerun this command. What I'm gonna do is instead of time mu index, time mu init. With the same flags, the mail dir flag and the my address flag. And that time I think it ran correctly. I didn't get the same kind of error messages. Let me clear the screen here. The next command I'm gonna run is time and then we're gonna do the mbsync command and give it this flag dash C for config. And then we need to give it the path to our config which in my case is at the dot config slash mu four E folder mbsync RC space. And then finally give it a dash A flag at the end. Run that command. If everything works correctly, it will download all of your emails locally and put them in the proper folders. Now in my case, it doesn't work. And the reason it doesn't work is for two reasons. One, Mary Sue dash distro tube doesn't actually exist. That's not a real email address. Derek at distro tube is a real email address, but his password is not password 1234. That's the reason it actually fills. So what I'm gonna do off camera is I'm gonna go back and create those GPG files with the right passwords so you can see the sync actually work correctly. All right, so I went back and created the GPG for mbsync dash account one again with my actual password. So now let me run that command again that mbsync command. I'm gonna run time mbsync space dash C space, the path to our mbsync RC file space dash A. And you can see it's actually downloading emails. Where is it storing them? Well, if I open up PC man FM again, and if I go into mail deer and to Derek distro tube, you see it created all of these folders, archive, drafts, inbox, sent. A lot of these folders were specified by the way in the mbsync RC file. You see the trash was just created here. But you can see it's downloading all of my messages locally on the system. And now when we launch Emacs and then launch MU4E, I should be able to actually read those emails inside Emacs. I'm gonna give this another couple of minutes here to download these messages. It looks like it's downloading 5,365 emails. All right, and that command completed. And since we timed it, it took two minutes and 22 seconds for it to download all of those emails. We did get an error, of course, from the fictional Mary Sue account, but that's fine. It actually downloaded Derek at distro tube.com's email. So if I open up Doom Emacs, I don't think I'm gonna need the terminal again. So let me close the terminal and let me toggle on big font mode so we can read. And if I do meta X and type MU4E to launch the MU4E email client, it's gonna say something about certain folders don't exist on the system. So any email folders that it wants to create, just type Y for yes and let MU4E create those. And there you go. This is MU4E. This is the home screen. You could U to update the email and the database. Now, since I just ran that command in the terminal to pull down my messages, I know they're up to date, but you to update, you could also type capital J to jump to a mail directory. So if I type J, it lists all the available folders I could go to. And I have hotkeys in my config.org that allow me to jump between inbox and sent and trash. So if I type I on the keyboard right now, you can see it will go to Derek distro tubes inbox. And there you go. This is my email. If I wanted to go down here and read one of these emails. So maybe I wanted to read this latest message from the AUR mailing list here. I don't know what this message is about, but it's a public mailing list. So no harm in reading this. You can see, you just click on it. You can read it when you're done with it. Type Q on the keyboard for quit. And then just move down to the next email you want to read. For those of you wanting to learn how to use MU4E, it's pretty intuitive to use. You could always just look up the commands within Emacs itself or do a quick search on the web. But that's really beyond the scope of this video. This video was mainly to show you guys how to set up MU4E in Doomy Max, because it is tricky, right? We had to install a couple of different packages from the AUR, MU and MB sync dash yet. And then we had to add a little bit of code to our config.el and our packages.el. And we had to rebuild Doomy Max. We had to create several directories on the system, including the dot config slash MU4E directory along with our MB sync RC config file. Then we had to create our plain text password files. Then we had to GPG encrypt those password files, delete the plain text files. Then in our home directory, we needed to create the mail-deer directory. And then within the mail-deer directory, we had to create directories for each of our email accounts for their email stores. Because of all that, you guys can see why it's taken me a while to get around to making this MU4E video. Because even after going through all of what I just went through and showing you guys how to set this up, really what I set up works for my email accounts. I don't know if it's gonna work for your email accounts because most of you guys have a Gmail account. I don't know anything about Gmail. I don't know what your MB sync RC file should look like for Gmail, but I will tell you that I will post a couple of links to some post on R slash Emacs. Because I found a couple of really nice posts about setting up MU4E on R slash Emacs. Matter of fact, this post here, MU4E for dummies was posted over a year ago. I actually have this bookmarked and I've had it bookmarked ever since I first started using Emacs. Because I always check this out when I set up MU4E. This has always been my guide to setting it up. And most of what I did on camera today was commands directly from this Reddit post. Now those of you that are using Gmail, I also found this Reddit post here. I'm also gonna link to this in the show description. How to easily manage your emails with MU4E also from R slash Emacs. And it looks like this guy is a Gmail user. So you might check out his settings and how he's setting up his MB sync RC for his Gmail account. Between my video and these Reddit posts though, I think you guys should be able to work it out and get your email client working within Emacs because whoever wants to leave Emacs, once you open it up, you wanna be in that thing, right? Now before I go, I need to thank a few special people. I need to thank the producers of the show. I need to thank Devin Fran, Gabe Corbinian, Mitchell Akami, R5530, Chris Chuck, David. The other David, Donnie, Dylan, Gregory, Lewis. I lost count, Paul, PicVM, Scott, Willie. Hope I named everybody. They are my highest tier patrons over on Patreon. They are the producers of this episode. I also wanna thank each and every one of these, ladies and gentlemen. These are all my supporters over on Patreon because without these guys, this episode about the MU4E email client within Emacs, it wouldn't have been possible. If you'd like to support my work, consider doing so. Look for DistroTube over on Patreon. All right guys, peace.