Luke Smith ab2a2f0d89 | il y a 4 ans | |
---|---|---|
FUNDING.yml | il y a 4 ans | |
LICENCE | il y a 4 ans | |
README.md | il y a 4 ans | |
emailwiz.sh | il y a 4 ans | |
mailrm.sh | il y a 5 ans |
I wrote this script during the gruelling process of installing and setting up an email server. It perfectly reproduces my successful steps to ensure the same setup time and time again.
I’ve linked this file on Github to a shorter, more memorable address on my website so you can get it on your machine with this short command:
curl -LO lukesmith.xyz/emailwiz.sh
When prompted by a dialog menu at the beginning, select “Internet Site”, then
give your full domain without any subdomain, i.e. lukesmith.xyz
.
Read this readme and peruse the script’s comments before running it. Expect it to fail and you have to do bug testing and you will be very happy when it actually works perfectly.
mail.
subdomain.
Create a nginx/apache site at mail.<yourdomain.com>
and get a certificate
for it with Let’s Encrypt’s Certbot.mail.
subdomain.mail.<yourdomain.com>
. If you would like IPV6, you can do the same for
that. This has been tested on Vultr, and all decent VPS hosts will have
a section on their instance settings page to add a reverse DNS PTR entry.
You can use the ‘Test Email Server’ or ‘:smtp’ tool on
mxtoolbox to test if you set up
a reverse DNS correctly. This step is not required for everyone, but some
big email services like gmail will stop emails coming from mail servers
with no/invalid rDNS lookups. This means your email will fail to even
make it to the receipients spam folder; it will never make it to them.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.Let’s say we want to add a user Billy and let him receive mail, run this:
useradd -m -G mail billy
passwd billy
Any user added to the mail
group will be able to receive mail. Suppose a user
Cassie already exists and we want to let her receive mail to. Just run:
usermod -a -G mail cassie
A user’s mail will appear in ~/Mail/
. I you want to see your mail while ssh’d
in the server, you could just install mutt, add set spoolfile="+Inbox"
to
your ~/.muttrc
and use mutt to view and reply to mail. You’ll probably want
to log in remotely though:
Let’s say you want to access your mail with Thunderbird or mutt or another email program. For my domain, the server information will be as follows:
mail.lukesmith.xyz
mail.lukesmith.xyz
luke
(I.e. not luke@lukesmith.xyz
)The last point is important. Many email systems use a full email address on login. Since we just simply use local PAM logins, only the user’s name is used (this makes a difference if you’re using my mutt-wizard, etc.).
You’re a big boy now if you have your own mail server!
You can tweak Postfix (sending mail
If this script or documentation has saved you some frustration, you can donate to support me at lukesmith.xyz/donate.
journalctl -xe
to see the specific problem.