Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 4 Jahren
vor 4 Jahren
vor 5 Jahren
vor 5 Jahren
vor 4 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 4 Jahren
vor 5 Jahren
vor 4 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # Email server setup script
  2. I wrote this script during the gruelling process of installing and setting up
  3. an email server. It perfectly reproduces my successful steps to ensure the
  4. same setup time and time again.
  5. I've linked this file on Github to a shorter, more memorable address on my
  6. website so you can get it on your machine with this short command:
  7. ```
  8. curl -LO lukesmith.xyz/emailwiz.sh
  9. ```
  10. When prompted by a dialog menu at the beginning, select "Internet Site", then
  11. give your full domain without any subdomain, i.e. `lukesmith.xyz`.
  12. Read this readme and peruse the script's comments before running it. Expect it
  13. to fail and you have to do bug testing and you will be very happy when it
  14. actually works perfectly.
  15. ## This script installs
  16. - **Postfix** to send and receive mail.
  17. - **Dovecot** to get mail to your email client (mutt, Thunderbird, etc).
  18. - Config files that unique the two above securely with native log-ins.
  19. - **Spamassassin** to prevent spam and allow you to make custom filters.
  20. - **OpenDKIM** to validate you so you can send to Gmail and other big sites.
  21. ## This script does _not_
  22. - use a SQL database or anything like that.
  23. - set up a graphical interface for mail like Roundcube or Squirrel Mail. If you
  24. want that, you'll have to install it yourself. I just use
  25. [isync/msmtp/mutt-wizard](https://github.com/lukesmithxyz/mutt-wizard) to
  26. have an offline mirror of my email setup and I recommend the same. There are
  27. other ways of doing it though, like Thunderbird, etc.
  28. ## Requirements
  29. 1. A **Debian or Ubuntu server**. I've tested this on a
  30. [Vultr](https://www.vultr.com/?ref=8384069-6G) Debian server and one running
  31. Ubuntu and their setup works, but I suspect other VPS hosts will have
  32. similar/possibly identical default settings which will let you run this on
  33. them. Note that the affiliate link there to Vultr gives you a $100 credit
  34. for the first month to play around.
  35. 2. **A Let's Encrypt SSL certificate for your site's `mail.` subdomain**.
  36. Create a nginx/apache site at `mail.<yourdomain.com>` and get a certificate
  37. for it with Let's Encrypt's [Certbot](https://certbot.eff.org/).
  38. 3. You need two little DNS records set on your domain registrar's site/DNS
  39. server: (1) an **MX record** pointing to your own main domain/IP and (2) a
  40. **CNAME record** for your `mail.` subdomain.
  41. 4. **A Reverse DNS entry for your site.** Go to your VPS settings and add an
  42. entry for your IPV4 Reverse DNS that goes from your IP address to
  43. `mail.<yourdomain.com>`. If you would like IPV6, you can do the same for
  44. that. This has been tested on Vultr, and all decent VPS hosts will have
  45. a section on their instance settings page to add a reverse DNS PTR entry.
  46. You can use the 'Test Email Server' or ':smtp' tool on
  47. [mxtoolbox](https://mxtoolbox.com/SuperTool.aspx) to test if you set up
  48. a reverse DNS correctly. This step is not required for everyone, but some
  49. big email services like gmail will stop emails coming from mail servers
  50. with no/invalid rDNS lookups. This means your email will fail to even
  51. make it to the receipients spam folder; it will never make it to them.
  52. 5. `apt purge` all your previous (failed) attempts to install and configure a
  53. mailserver. Get rid of _all_ your system settings for Postfix, Dovecot,
  54. OpenDKIM and everything else. This script builds off of a fresh install.
  55. 6. Some VPS providers block port 25 (used to send mail). You may need to
  56. request that this port be opened to send mail successfully. Although I have
  57. never had to do this on a Vultr VPS, others have had this issue so if you
  58. cannot send, contact your VPS provider.
  59. ## Post-install requirement!
  60. - After the script runs, you'll have to add additional DNS TXT records which
  61. are displayed at the end when the script is complete. They will help ensure
  62. your mail is validated and secure.
  63. ## Making new users/mail accounts
  64. Let's say we want to add a user Billy and let him receive mail, run this:
  65. ```
  66. useradd -m -G mail billy
  67. passwd billy
  68. ```
  69. Any user added to the `mail` group will be able to receive mail. Suppose a user
  70. Cassie already exists and we want to let her receive mail to. Just run:
  71. ```
  72. usermod -a -G mail cassie
  73. ```
  74. A user's mail will appear in `~/Mail/`. I you want to see your mail while ssh'd
  75. in the server, you could just install mutt, add `set spoolfile="+Inbox"` to
  76. your `~/.muttrc` and use mutt to view and reply to mail. You'll probably want
  77. to log in remotely though:
  78. ## Logging in from Thunderbird or mutt (and others) remotely
  79. Let's say you want to access your mail with Thunderbird or mutt or another
  80. email program. For my domain, the server information will be as follows:
  81. - SMTP server: `mail.lukesmith.xyz`
  82. - SMTP port: 587
  83. - IMAP server: `mail.lukesmith.xyz`
  84. - IMAP port: 993
  85. - Username `luke` (I.e. *not* `luke@lukesmith.xyz`)
  86. The last point is important. Many email systems use a full email address on
  87. login. Since we just simply use local PAM logins, only the user's name is used
  88. (this makes a difference if you're using my
  89. [mutt-wizard](https://github.com/lukesmithxyz/mutt-wizard), etc.).
  90. ## Tweaking things
  91. You're a big boy now if you have your own mail server!
  92. You can tweak Postfix (sending mail
  93. ## Benefited from this?
  94. If this script or documentation has saved you some frustration, you can donate
  95. to support me at [lukesmith.xyz/donate](https://lukesmith.xyz/donate.html).
  96. ## Troubleshooting -- Can't send mail?
  97. - Always check `journalctl -xe` to see the specific problem.
  98. - Go to [this site](https://appmaildev.com/en/dkim) to test your TXT records.
  99. If your DKIM, SPF or DMARC tests fail you probably copied in the TXT records
  100. incorrectly.
  101. - If everything looks good and you *can* send mail, but it still goes to Gmail
  102. or another big provider's spam directory, your domain (especially if it's a
  103. new one) might be on a public spam list. Check
  104. [this site](https://mxtoolbox.com/blacklists.aspx) to see if it is. Don't
  105. worry if you are: sometimes especially new domains are automatically assumed
  106. to be spam temporaily. If you are blacklisted by one of these, look into it
  107. and it will explain why and how to remove yourself.