 In this video I'm going to tell you how you can easily download any email from any email account that you have access to, doesn't matter if it's your own email server, doesn't matter if it's Google or Yahoo or anything. You can use this program iSync to download and sync any kind of mail repository. Maybe you want to download all your mail just to have a backup of everything. Maybe you want to download your mail because you don't want Google to have direct access to it all the time. Or maybe as I talked about a couple videos ago you want to use MUT or another offline client for accessing your email offline. For any of those use cases iSync is a great program. You can use it once to download all your mail and you can run it again and it will download new mail, sync everything. You can make changes in the way you want and there are a lot of different ways you can set it up to get the exact kind of setup you want. I'm going to talk about iSync in this video. It's easy to download. It's pretty much in every Linux repository. It's nothing too special. To be clear, iSync is the name of the project, mbsync is the name of the executable. The program you actually run is called mbsync and we're going to be making really one config that that program uses and it's going to have all the info in it. Anyway, let's just do it. I'm going to set up... Well, I should say there is some information you need to know. You probably already know it. You need, of course, an account. Here is a junk email account I made and here is its password. You might not know your email server's IMAP address so you need to get your server address and your port. Your port number is nearly certainly 993 but your server might be... I think it's mail.gmail.com if you have a Gmail. Just look it up. They always provide them but you just need your IMAP server and your IMAP port and additionally you need to know where your CA certificate is. You probably have one of these installed. You just need to know where on your system it is. You don't even need to know what it is. You just need to know where it is on your system. For most Linux distributions, I think it's here. At least it is. I'm using Arch Linux and I have it there and for Mac OS people tell me that that's where it is but you might want to double check. But once you know that, you should be pretty good. I should say for Gmail users, I make a little note here, you're going to want to allow what they call less secure applications to access your Google account. That really means third party applications. They're just trying to scare you but allow that and then you'll be able to log in with your credentials and download your email. But anyway, most people don't have to do that unless you have Gmail. It's actually pretty easy to set this up so let's do it really quickly. I am going to, the relevant config file I should say is mbsyncrc. So I'm going to open this up. It's blank so I'm going to start adding some stuff. And the first thing I'm going to do is I'm going to give it the information for the remote IMAP or really the email server and the username and password we log in and then I'm going to give it the information of where I want the mail stored on my computer and then the settings for how they sync. That's basically what we're going to do. So let's give it, first off we're going to say IMAP store and we're going to name. This is going to be all the information for the remote repository that we're logging into. So my junk email account is mutt at cock.ly. I'm just going to call my remote repository cock remote, okay? So you can name it pretty much anything you want as long as it syncs with how you call it. So the host, you're going to want to give it a host and that is going to be your IMAP server. In my case it's mail.cock.ly. I'm going to give it a port and that's 993. It's nearly always 993 but yours could be different. You might want to look it up. And I'm going to have user. User is going to be my email address. So cock or mutt at cock.ly and password. I'm going to put in my password. Now when it comes to passwords, there are multiple things you can do. One, you don't actually need to include your password here. And if you do not include it, if you run mbsync, it's just going to ask you for your password each time. But I'm going to put it in here. You can also say pass command and then give it some kind of command to run to get your password. If you have something like, you know, pass or something to or some kind of password manager, you can use that. But I'm going to be lazy. I'm just going to put the password here, you know. We'll talk about that in another video. So you include that and you'll also want to say the SSL type and we want to log in with, you know, IMAP secure. And we're going to, because of that, I think we need to put a certificate, certificate file. And the certificate file is going to be that little, this file down here that I mentioned just a second ago. So I'm going to copy this in here. So there's where my certificate file is going to be. Okay, so that should be all the things that we need to log into the server. Now we want to set where we want this mail to be kept on our computer. Okay, so I'm now going to say mail dear store. And I'm going to name it cock local. Okay, because this is going to be our local repository of the cock.ly account. Okay, now it's pretty simple enough to do. So for the path, the path is basically just going to be the location of the mail. I'm going to put it in let's say mail cock. And importantly, you want to include a trailing slash here. That's important because it'll do really weird stuff if you don't include a trailing slash here. Now you also have to put an inbox. I actually don't know if you actually have to put this, but I'm going to put it anyway. So you're going to want to say mail cock and the name of your inbox, which is nearly always capital inbox. I don't think you need a trailing slash here, but the last thing you want to do is say sub folders and you want to say verbatim. Now what this means here is that so mail servers will sometimes, well by default, I'll just say isync will look at mail server file folders and they will rename them or do weird things for them. Basically the setting here says, okay, when you see sub folders in this mail repository, just create folders on the local machine. That's what we want, okay? So that's all that does. Now once we have that, so we have the information for the both the remote and local accounts, we want to put those together and provide settings for how they sync, okay? And that's all we have to do. So we create a channel and I'm going to name the channel cock because we're just talking about cock so much in this video. Now you're going to set a master and that is going to be cock remote and that's saying basically this thing here, that the thing we called cock remote, that is going to be, that's the main channel that we're getting all this stuff from. I'm actually going to move this or maybe, oh yeah, going to move this thing. And we're going to put a slave account which is going to be cock local, okay? Now additionally, I'm going to put a couple other settings and I'm going to explain what they do and I think they're all pretty important, okay? So one is create and I'm going to put both. I'm going to put expunge both. I'm going to put patterns star and I'm going to put sync state star, okay? So what do all these means? Create an expunge, basically create both means if I create a folder or a new box on one repository, the next time I run mbsync, I want you to create that folder on the other repository. If you don't include this, new folders will not be created or stuff like that. Expunge is sort of similar but with deletion. So if I am on my own machine, say I download my mail with isync and I'm using a client on my computer where I delete some emails. Now if you don't have expunge both, once you sync it, the emails in your remote repository, they will be marked as deleted. They'll have like a line through them on Gmail or something but they won't actually be deleted. And usually if you delete them, you actually want them deleted. So I put expunge both. But you know, you can play around with the settings. The other two things that are important are patterns. Patterns determines which mailboxes to sync and if we give it the star, that means all the mailboxes, inbox, synth, whatever, sync them all regardless of what they look like. And importantly, sync state, it's important to explain what this is or you could just copy it, sync state star. Basically, how MBSync works is that it keeps little files that detail what kind of, you know, when the last time you did a download and what kind of files have changed remotely or whatever. Basically, by default, those files are kept elsewhere but if you give it a star, those files are kept within the mailbox. Now why this is important, basically, if you delete, let's say hypothetically, I download all my mail and I move the folder that, you know, my mail was downloaded to. And then I inadvertently run the program again or something like that. In that case, it's going to assume that I meant to delete everything. So it's gonna delete everything locally. But if you have sync state and it's keeping its sync files with the same folder, it's gonna say, oh, I don't see the sync file. So I'm just going to assume that you meant to redownload this or something, which is a less disastrous error. Anyway, so that's a lot of talking, but we're actually to the point where we have everything. Okay, so again, it pretty simple settings. Let's go ahead and run this. And we'll hope it works because I'm sort of ad-libbing this. Now how you run it is just in B sync and you can give it the A option and that is gonna run all channels. It's gonna run everything that you've put in here or you could just say cock in my case since I named this channel cock. So I'm gonna run it. Let's hope it works, okay. Oh yeah, okay, silly. One other thing. So it says, cannot open store mail cock. You do actually need to manually create the directories they belong in. So I'm gonna create mail cock. Now I'm gonna run it. Hope that works. Yeah, so now it's working. You see that these little errors here, this is it creating the sync information. It's not an error. It's just it notifying you that it's working basically. The second time you run it, it's not gonna do that. And I will say you can also run it with the V option and it will show you specifically what it's doing. So it's saying, okay, I'm going through all this. I see all this mail, whatever. Okay, so what that now has done is we can go to mail cock and we can see that it's now actually downloaded all this stuff. In fact, it has all our mailboxes here and if I run some kind of command you'll see that all of these mail files are now in here. Okay, so that is very nice. So how do you open these? There are different ways to do it. Different mail clients can do it. Just know that if you don't know, this is already useful because you've already backed up your mail. I don't have very much in this junk mailbox, but so let's say you watched my video a couple of days ago on mutt and you want to get this, you want mutt to look at this kind of mail. How do you do it? It's actually pretty simple. So I'm going to go, I actually have set the settings that I set in that video and I'm just going to show you how it works. Now by default, mutt is looking, well, let's see, how we set it up last time is if I open mutt, it is looking to this remote folder, which is an IMAP server. It's actually the same IMAP server we just synced with. So if I run mutt, it is actually connecting to the server. You see connecting, blah, blah, blah. It's waiting a little bit. It's actually running a little slow today. And here we've logged into the server and we're looking at this mail, not the mail on our computer, but the mail that's on the server. But what we can do, I'm going to exit out of here, what we can do instead of having this as a IMAP or some kind of remote folder, we can actually just say, let's say mail cock. That's the directory our mail is in. So now if I open this up, notice it opened instantaneously. Now it's not loading the internet. It's actually loading these files that are on your computer. So if you look at this, you'll see, of course, there's all a bunch of mail that I just created for no reason. But you can open these up pretty easily and see that, oh, look at all this. We got all this mail. Isn't that fantastic? So that's pretty much how you do it. So anyway, you can set up, there are a lot of other settings in MBSync and of course mutt. I'll probably do more mutt videos relatively soon. But if you want to check the MBSync manual, I highly recommend you do that. There are a lot of different settings for the kind of things, kind of defaults you might want or the kind of just read the manual. That's all I can recommend. But so hopefully that helps you guys out. If you have any questions, read the manual first, but then ask in the comments or something and I will see you guys next time.