Gmail's dumb: Just host your own mail server!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right it's time a lot of you have been waiting for a video on how to set up an email server so that's what we're gonna do in this video so it is that setting up an email server is actually a notoriously difficult process but last year I'm very glad I did this last year when I set up my own email server it was very painful but once I finally figured it out I actually sort of left a rope for myself in that I wrote a script that did most of the work for you and installs the dependencies and configures them all together so I'm gonna be using that in this and you can of course as well it's on my github but I also want to explain the logic of an email server and some stuff about it okay so what a email server usually in consists in is a postfix server which sends mail a dovecot server which receives mail you have to configure them together you got to make sure they're they're locking into with each other you'll usually want spamassassin to keep you know get spam away and we'll be installing that as well and one of the biggest questions I get when talking about email server or like let's say you have your own domain a lot of people have the idea that oh if I just have some random domain I might send mails to Google or something like Gmail and they might get blocked so we're also gonna set up open DKIM which allows it basically validates your domain and your email as legitimate and it's a way to you know so spam filters won't get you and stuff like that now in order to do all this you are going to need some kind of EPs this script that I have made works on Debian and Ubuntu I have tried it on both I've tried it on volts or VPS --is so I know some of you guys are using it because I I did so it might work on if you have another VPS provider ligh node or digitalocean but I know they work for vulture we are going to be creating a SSL certificate that is we want encrypted connection to our server so we'll be setting that up now the first thing we want to do though is we want to actually set up some DNS records okay so go to your registrar or wherever you set you know if you have a DNS server you can open that but we're gonna want to add some DNS records so here again my website you know boomer calm looking at the DNS records the big one is you want to go make an MX record and now an MX record is basically just the record did not mean to do that it's the record that basically tells whoever's trying to email your domain where to look you know we're to actually send your mail so we're gonna add an MX record and my face is like how to sync that sort of annoys me I don't know it's been doing that a lot today not quite sure why so we are going to add an MX record and basically it doesn't just host leave a blank you can put mail and then your site after it and you want at the very end a trailing dot that is if you're using epoch I think I think other other registrar's don't necessarily require that but um so if you go to you also want to set up so we're gonna send dollar to our email server basically is going to be at mail dot whatever you know your website so we're telling it to go there and additionally we're gonna want to set up that sub domain as well so you want to make a cname record for that and this is more actually to figure out this is more to make certain Bach work but we're gonna go ahead and make that we're gonna make a cname domain for mail and we're gonna direct that to you new boomer comm with a trailing period once again and for good measure I'm just gonna put in wwl I always do that I always double up putting in w WS for my subdomains oh I gotta remember that trailing period so once you have that you can save that and you're done with your DNS records for now we'll actually come back here at the very end we're gonna add some text records that have to do with DKIM so you can validate your emails and stuff like that alright so once you have that I'm gonna go over here actually maybe I'll bring my face cuz you know I always I feel lonely if I'm on a workspace alone I am going to log into my website okay so now I'm here now the script that I made you can get it at this link right here okay you can download it from my website Luke's method XYZ / email whiz Sh so let's do that okay so Luke Smith XYZ email Wiz message okay so now we're gonna download that but before we even run that there's one more thing we want to do we want to actually configure that sub domain so that it can take encrypted connections so you know we we want to use cert bot to give it HTTP and stuff like that so let's do that first so how we want to do that we want to create a dummy domain in a sub domain in engine X so if you remember from the videos before engine X which is our web server it keeps its available sites in Oetzi slash engine X slash sites available okay I feel like my web cam is like off sync just so much today I don't know maybe I'm just imagining it but anyway so in this folder I've actually already created a file called mail so I'm gonna open this up and this is you just want to create a file that looks like this you can name it mail you can name it whatever so long as it has this kind of information you want to listen on port 80 if you have ipv6 you want to have this line as well you can give it just some random root directory it doesn't actually matter where I I'm just gonna give it mail we're not actually gonna set up like a web site at this location it's just gonna be a dummy web site to get you know our certificate and but the important thing is your server name should be male dot whatever calm and WW male okay now once you have that you can activate that site by taking that file and linking it I'm gonna link it make a symbolic link from there two sites enabled okay once that happens engine X will treat that as a real site and we will tell we will reload engine X okay once you do that we can go ahead and it's a get SSL for that get encryption will run that and it will ask what domains you want to do I'm gonna pick mail and wwl and that'll take a second not too long and it'll ask you want to redirect say yes if you haven't run it before of course it'll ask you for your email and stuff and other things but alright so that should be done okay so now let's test that I always leave in my face behind if we should be able to go to mail you know boomer comm and you should get this yes we got an error but this is the correct error you want to have like engine X error so just to be clear if you typed in some random letters and then typed a sub-domain it would have this but what we want to see is this okay and notice also up here it says connection is secure that means it works so great we're basically halfway there alright so the other half is more or less running the script that I made okay so this script is going to install postfix and dovecot and configure them together it's gonna install spamassassin everything else let me just go ahead and start it it will start by downloading some of these programs and it's gonna ask you oh yeah this I think I already down downloaded them I just haven't installed them so it's gonna bring up a menu like this say internet site and then it's gonna ask you you for your system mail name just put in your domain name you know boomer x.com don't put in mail before it just put in you know the the clean domain and so that should take a little bit of time I'll probably stop this because it might take a little bit but what this is gonna do it's gonna be installing you can see what it's doing it's installing postfix and dovecot and all the other things that are required and actually in this script maybe we can look at the script in the meantime email wiz yeah yeah in this script there's just a bunch of configuration that goes on that I make it do manually it sets up like what your your mailboxes are gonna look like you know what their name drafts junk inbox sent trash archive archive I didn't even know I added that but um and then all this complex stuff it was such a pain figuring out all this stuff and configuring them with spamassassin but how it's gonna work once this is done is you whenever you create a user actually we can go ahead and do this we can go ahead and do this actually so I'm gonna login to my server so now I'm gonna have two instances into my server it's apparently taking a while I'll just okay so one thing how you set up email accounts or I mean we can go ahead and start doing this oh you want to add users let's say I want to be named Ted okay I want the mail account Ted at Unabomber calm okay what you can go ahead and do is say user add and then you can say you want to say M that means automatically create create this users home directory you want to do capital G and that means this is a group that this person's gonna be added to and add mail basically that means whenever you add a user to the mail group that means that they are going to be able to you know receive mail send mail stuff like that and Ted is the thing we're going to the name we're gonna give actually I'm gonna keep make the shell for this guy Ben dot bash I think it's s for changing the show alright that should work okay so we went ahead and made him and you'll also definitely want to give him a password in fact you need a password in order to be in order to log on we will deal with that in a second so I'm just gonna make up a little password for him okay now okay great perfect that's perfect timing because now it looks like our script is done it's installed all the stuff we need but there's still stuff we need to do okay that's why there's this big now thing okay so there are three text records that we have to add to our little text record tab over here on our DNS records so to be clear these are also saved in my script I think I saved them to like DNS yeah they're saved to this file if you lose track of them but so basically these are like DKIM this first one is DKIM to validate your email or yeah validate your domain and stuff like that so let's go ahead and add this so you if you put it in manually I think you have to include like the entire domain I think I can get away with just including the sub domain if I let's see add record the host is going to be that sub domain and then the text entry is going to be everything from V to the end of the line this first one's gonna be really really long but yeah you can just put that in there then we're gonna add two other ones so we're gonna add one for addy mark so these two are basically gonna be I don't know if you know this but it's actually really easy to spoof emails so these two things are to avoid you know basically to prevent that from happening on your server so I'm gonna add that in and I'm gonna add this last one in copy this and hopefully this will all work if it doesn't I will fix it live and you will know what is happening okay so I'm going to save those saving them okay come on in the meantime I have actually taken the unusual step of okay should be saved I've taken the unusual step of installing Thunderbird because now Thunderbird or any other mail application we can now use to install you know basically login to our server okay now of course I usually use mutt but we'll use Thunderbird because it's more you know nor me friend okay so let's do this so we will just set up an email account and I'm gonna say my name is Ted my email address is Ted at Unabomber comm my password I'm gonna put in my password okay so it's gonna take a little bit of time thunderbird i think has some abilities to automatically guess what your mail information is i'll go ahead and say that i actually chose very normal things for basically if you're using a program that requires you to put in like server information this is going to be your server information your smtp port again that's for sending mail that's going to be mail dot whatever your domain is and the port is going to be 587 that's typical i'm servus gonna be the same thing and the port is gonna be 993 and your username this is actually important because you might get confused by this your username is gonna be just the beginning it's just gonna be you know Luke instead of Luke at Luke Smith that XYZ right okay so let's see I think that'd work we'll see if that works I don't actually know how Thunderbird start TLS now I don't think it should be start TLS I feel like that well anyway we'll see if it works it's not going to alright well we'll do manual it would have made a connection by now okay this should be oh yeah this is done alright as I said I'm apps should be 993 and this should be SSL wait is it whatever yeah 585 87 mm car SSL okay maybe maybe I'm dumb I'm just gonna do put five every set 587 I don't know about that retest okay well just run with that let's see if that works okay so I have an inbox it seems to have logged in oh and it's detecting all my mail boxes so that so that means there's stuff here so I'm going to log on to my other email address and I'm gonna send email to the server to make sure it works okay let's do that okay so here is a test email okay so again we're sending to Ted at Unabomber calm test email let's see if that works it's gonna send hopefully and it's gonna appear here in just a second let's see is there a refresh button oh look at that look at that that's beautiful so here's our mail we can now receive mail now the big test is can we can we like send mail to other places and let's say Gmail ok Gmail is usually the hard one because they you know they're very picky about DNS settings and stuff like that so let's test this out so I'm gonna send it to this gmail account that I have I'm gonna say let's see if open the kam or it's gonna be the title of our email let's see if this works best Luke no we'll do Ted okay so I will send that now usually if you if the male is undeliverable a lot of times you'll get an email back or something like that like that not all the time so I'm gonna log I mean I guess old let's see I'll just pull up a private browsing window and go in here log on to Gmail first time I view Gmail in awhile and here it is so we have our email got it from I don't know the source we wanted let's see it's standard encryption looks all everything looks good there's one additional test we can have or if you're having any problems this is one of the things you can do there are a couple sites out there I'm gonna take my face there are a couple sites out there like this one that will actually test your DKIM settings or your SPF settings we technically put in a record for that as well so what you can do is they will give you a dummy email address I'm gonna copy this email address and we can send if we want to test we can just send any old email to here okay I'll just put whatever and we'll send that and they will tell you if there's anything wrong with your settings or something like that so here we have the raw email right here it's it's encrypted and all this stuff that's as expected and it says it passes SPF passes dkim something's going on with Demark maybe it's still low yeah it's still loading let's hope it passes again like these settings are for you know making sure you don't like people don't spam or not spam like spoof emails it's actually really easy like you could just go and Mutt and just change your from address and pretend you're emailing from someone authoritative and of course SPF and Demark are to prevent that I don't know why this is taking so long I actually in the break I tried it already and it was working okay maybe I'll maybe we'll wait on that for a second in the meantime so as I said if you want to add if you want to add a new mail user you can always use user add you want to use em to add a new directory for them a G capital G I should say adds them to the mail group and you'll probably want to create a shell for them you know bin - and just name them whatever so let's name someone Billy okay and you'll definitely want to make a password for them as well if you already have a user that you want to add to the mail group because not all user not all users will automatically have the ability to send and receive mail you can say user mod a a not M capital G in mail and then say whatever the name is so let's say you know Billy already exists and we want to add them to the mail group we just run user mod and you know that'll do it so that should work with that is this gonna ever work I don't know anyway so that should be about it if you have a try it out for yourself if anything goes wrong there you can open up an issue on the github and stuff like that but in general I've been you know the the email that I'm using right now is run like I just installed it like last week had to reinstall my server so this script works I know a bunch of other people who have used it that it works if anything goes wrong though be sure to evaluate what's going on look at the source code and stuff like that and to be clear the configuration files I mean this goes for pretty much any program on Linux but if you want to look at system configuration go to Etsy and let's say you want to look at spamassassin okay you want to see what kind of rules you can make it in spamassassin you can look up how to add new rules here you can learn how to whitelist or blacklist particular things that's a good place to do it I I think I forget where exactly I add like I have a script offline that adds if I want to block an address it logs into my server and adds a line to spamassassin or something like that or the same thing if you want to change postfix again that's for sending mail if you want to changed some custom settings you can go into their main configuration and change some things but in general like a lot of the again my script sort of makes everything fit together so just bear that in mind if you change something it might affect two other other things but yeah so that's basically yeah that's how you use it and let's see everything I'll check in to what why this is not loading okay it's probably nothing though okay yeah this is just verification the Demark thing did work I just sent another email I think it was just the one time glitch or something I didn't change any other settings so yeah that should be fine all right yeah that's it
Info
Channel: Luke Smith
Views: 106,465
Rating: undefined out of 5
Keywords: email, server, mail, dovecot, easy, smtp, imap, postfix, send, receive, opendkim, spf, txt, cname, record, aaaa, dns, gmail, thunderbird, mutt, neomutt, google, yandex, private, https, ssl, certbot, 993, 587, clinton
Id: 9zP7qooM4pY
Channel Id: undefined
Length: 20min 15sec (1215 seconds)
Published: Mon Jun 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.