Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

README.md 6.1 KiB

5 anni fa
5 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Email server setup script
  2. *NOTE: If this line is here, I'm still testing this to even it out.*
  3. I wrote this script during the grueling process of installing an setting up a web server.
  4. It perfectly reproduces my successful steps to ensure the same setup time and time again.
  5. Deviate from one command and everything might fall apart unless you know better!
  6. I've linked this file on Github to a shorter more memorable address on my LARBS.xyz domain, so you can get it on your machine with this short command:
  7. ```
  8. curl -LO larbs.xyz/mailserver.sh
  9. ```
  10. When promped by a dialog menu at the beginning, select "Internet Site", then give your full domain without any subdomain, i.e. `lukesmith.xyz`.
  11. Read this readme and peruse the script's comments before running it.
  12. Expect it to fail.
  13. ## This script...
  14. - Installs a dovecot/postfix mail server for your domain of choice
  15. - Sets up sensible default mail boxes located in `~/Mail`
  16. - Installs and sets up Spam Assassin
  17. - Installs and sets up OpenDKIM which validates your emails so you can send to Google and other sites with picky spam filters
  18. ## This script does _not_
  19. - ...install or use a mySQL databse, instead uses the traditional Unix/PAM/login system where every user can be an email address on the domain.
  20. - ...set up a graphical interface for mail like Roundcube or Squirrel Mail. If you want that, you'll have to install it yourself. I just use [isync/msmtp/mutt-wizard](https://github.com/lukesmithxyz/mutt-wizard) to have an offline mirror of my email setup and I recommend the same. There are other ways of doing it though, like Thunderbird, etc.
  21. - ...offer any frills. If you want to change something, open the script up and change some variables.
  22. ## Info
  23. These are the main active ingredients:
  24. - Postfix - SMTP server (that's for sending mail)
  25. - Dovecot - IMAP server (that's for receiving/storing mail)
  26. - Spam Assassin - does what it sounds like. You can configure the rules you want. Read the manual.
  27. - OpenDKIM - This authenticates your server so big-name sites like Google won't consider _your_ mail spam.
  28. ## Requirements
  29. - `apt purge` all your previous (failed) attempts to install and configure a mailserver. Get rid of _all_ your system settings for Postfix, Dovecot, OpenDKIM and everything else. This script builds off of a fresh install.
  30. - A Debian *web server*. I suspect the script will run on Ubuntu as well prodided there aren't huge differences in the default setup.
  31. - An *MX record* in your DNS settings that points to your own main domain/IP. Unless you have your own DNS server, you'll put this setting on your domain registrar's site. Look up their documentation on how to do this, but it's usually really easy.
  32. - *SSL for your site's mail subdomain*, specifically for mail.yourdomain.tld with Let's Encrypt. the script will look to Let's Encrypt's generated configs. If you have some other SSL system, you can manually change the SSL locations in the script before running it and it should be fine.
  33. - After the script runs, you'll have to add an *additional DNS TXT record* which involved OpenDKIM key that it generates during the script.
  34. ## Don't get offended by this section
  35. My intention is to have this script working for me on my Debian web server which I have with Vultr.
  36. Different VPS hosts or distros might have a startup config that's a little different and I'm sure as heck not going to make sure everything works on every possible machine out there, please do not even ask.
  37. If a lot of people try this script and see that it werks as expected everywhere, then I might try to label it as such and try to make it universal, but think of this script as a script that works on my exact setup than has some educational comments for the uninitiated and only might work as intended.
  38. Configuring an email server is a living nightmare and that's why I made this script so I wouldn't have to do it again.
  39. Don't ask me to configure your email server unless you are paying me big bucks to do it.
  40. With this script and the comments in it, I've given you way more than I owe you.
  41. If something is broken, start a PR to fix it, but *do not* open Issues about some problem you have unless you have figured out a solution and are offering a way for me to add a small change that will make this script more robust.
  42. Your mindset in running this script should be "oh, look, it puts all the commands in a bash-readable format, so I can run it and troubleshoot errors as they come up.".
  43. The script works for me and if it works for you without a problem, be thankful and feel lucky because setting up email is usually just so much less forgiving.
  44. If you decide to start a VPS, specifically Vultr since I made this script and have tempered it most on their default setup,
  45. use [this referal link of mine](https://www.vultr.com/?ref=7914655-4F) because you get a free $50 credit, and if you stay on the site, eventually I get a kickback too.
  46. I honestly have to really strong preference of Vultr over other VPS providers, but they're about as cheap and reliable as it gets and if we can get free money, lol whatever click the link 👏👏.
  47. ## Details
  48. - A user's mail is in `~/Mail`. Want a new email address? Create a new user and just add them to the mail group. Now they can send and receive mail. Look up using aliases too if you want for more cool stuff. Dovecot should autocreate the directories as needed.
  49. - All dovecot configuration is just in `/etc/dovecot/dovecot.conf` instead of a dozen little config files. You can read those in `/etc/dovecot/conf.d/` for more info, but they are not called by default after running this script and the needed settings are edited into the main config.
  50. - Your IMAP/SMTP server will me `mail.yourdomain.tld` and your ports will be the typical ones: 993 for IMAP and 587 for SMTP.
  51. - Using non-encypted ports is not allowed for safety! The login is with plaintext because that's simpler and more robust given SSL's security.
  52. - As is, you will use your name, not full email to log in. E.g., for my `luke@lukesmith.xyz` address, `luke` is my login. It seems that `luke` has to be my From: address in `msmtp` too, which is weird (it appears as a full address once I send mail though). I might look into changing this. Tell me if you know what to change.