浏览代码

resolve merge conflict with ssl update

pull/91/head
kgskgs 4 年前
父节点
当前提交
ceda9f02b7
共有 2 个文件被更改,包括 36 次插入30 次删除
  1. +21
    -27
      README.md
  2. +15
    -3
      emailwiz.sh

+ 21
- 27
README.md 查看文件

@@ -1,28 +1,24 @@
# Email server setup script

I wrote this script during the gruelling process of installing and setting up
I wrote this script during the grueling 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:

```
```sh
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.

## This script installs

- **Postfix** to send and receive mail.
- **Dovecot** to get mail to your email client (mutt, Thunderbird, etc).
- Config files that unique the two above securely with native log-ins.
- **Dovecot** to get mail to your email client (mutt, Thunderbird, etc.).
- Config files that link the two above securely with native log-ins.
- **Spamassassin** to prevent spam and allow you to make custom filters.
- **OpenDKIM** to validate you so you can send to Gmail and other big sites.

@@ -50,19 +46,19 @@ actually works perfectly.
server: (1) an **MX record** pointing to your own main domain/IP and (2) a
**CNAME record** for your `mail.` subdomain.
4. **A Reverse DNS entry for your site.** Go to your VPS settings and add an
entry for your IPV4 Reverse DNS that goes from your IP address to
`<yourdomain.com>` (not mail subdomain). If you would like IPV6, you can do
entry for your IPv4 Reverse DNS that goes from your IP address to
`<yourdomain.com>` (not mail subdomain). 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
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](https://mxtoolbox.com/SuperTool.aspx) 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
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.
make it to the recipients spam folder; it will never make it to them.
5. `apt purge` all your previous (failed) attempts to install and configure a
mailserver. Get rid of _all_ your system settings for Postfix, Dovecot,
mail server. Get rid of _all_ your system settings for Postfix, Dovecot,
OpenDKIM and everything else. This script builds off of a fresh install.
6. Some VPS providers block port 25 (used to send mail). You may need to
request that this port be opened to send mail successfully. Although I have
@@ -105,27 +101,23 @@ email program. For my domain, the server information will be as follows:
- SMTP port: 587
- IMAP server: `mail.lukesmith.xyz`
- IMAP port: 993
- Username `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](https://github.com/lukesmithxyz/mutt-wizard), etc.).

## Tweaking things

You're a big boy now if you have your own mail server!

You can tweak Postfix (sending mail
In previous versions of emailwiz, you also had to log on with *only* your
username (i.e. `luke`) rather than your whole email address (i.e.
`luke@lukesmith.xyz`), which caused some confusion. This is no longer the
case.

## Benefited from this?

If this script or documentation has saved you some frustration, you can donate
to support me at [lukesmith.xyz/donate](https://lukesmith.xyz/donate.html).
I am always glad to hear this script is still making life easy for people! If
this script or documentation has saved you some frustration, you can donate to
support me at [lukesmith.xyz/donate](https://lukesmith.xyz/donate.html).

## Troubleshooting -- Can't send mail?

- Always check `journalctl -xe` to see the specific problem.
- Check with your VPS host and ask them to enable mail ports. Some providers
disable them by default. It shouldn't take any time.
- Go to [this site](https://appmaildev.com/en/dkim) to test your TXT records.
If your DKIM, SPF or DMARC tests fail you probably copied in the TXT records
incorrectly.
@@ -136,3 +128,5 @@ to support me at [lukesmith.xyz/donate](https://lukesmith.xyz/donate.html).
worry if you are: sometimes especially new domains are automatically assumed
to be spam temporaily. If you are blacklisted by one of these, look into it
and it will explain why and how to remove yourself.
- Check your DNS settings using [this site](https://intodns.com/), it'll report any issues with your MX records
- Ensure that port 25 is open on your server. [Vultr](https://www.vultr.com/docs/what-ports-are-blocked) for instance blocks this by default, you need to open a support ticket with them to open it. You can't send mail if 25 is blocked

+ 15
- 3
emailwiz.sh 查看文件

@@ -38,7 +38,7 @@ apt install postfix dovecot-imapd dovecot-sieve opendkim spamassassin spamc
# Check if OpenDKIM is installed and install it if not.
which opendkim-genkey >/dev/null 2>&1 || apt install opendkim-tools
domain="$(cat /etc/mailname)"
subdom="mail"
subdom=${MAIL_SUBDOM:-mail}
maildomain="$subdom.$domain"
certdir="/etc/letsencrypt/live/$maildomain"

@@ -66,6 +66,15 @@ postconf -e "smtpd_use_tls = yes"
postconf -e "smtpd_tls_auth_only = yes"
postconf -e "smtp_tls_security_level = may"
postconf -e "smtp_tls_loglevel = 1"
postconf -e "smtp_tls_CAfile=$certdir/cert.pem"
postconf -e "smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1"
postconf -e "smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1"
postconf -e "smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1"
postconf -e "smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1"
postconf -e "tls_preempt_cipherlist = yes"
postconf -e "smtpd_tls_exclude_ciphers = aNULL, LOW, EXP, MEDIUM, ADH, AECDH, MD5,
DSS, ECDSA, CAMELLIA128, 3DES, CAMELLIA256,
RSA+AES, eNULL"

# Here we tell Postfix to look to Dovecot for authenticating users/passwords.
# Dovecot will be putting an authentication socket in /var/spool/postfix/private/auth
@@ -132,9 +141,13 @@ echo "# Dovecot config
ssl = required
ssl_cert = <$certdir/fullchain.pem
ssl_key = <$certdir/privkey.pem
ssl_min_protocol = TLSv1.2
ssl_cipher_list = ALL:!RSA:!CAMELLIA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SHA1:!SHA256:!SHA384:!LOW@STRENGTH
ssl_prefer_server_ciphers = yes
$dovecot_dh
# Plaintext login. This is safe and easy thanks to SSL.
auth_mechanisms = plain login
auth_username_format = %n

protocols = \$protocols imap

@@ -239,7 +252,7 @@ chmod g+r /etc/postfix/dkim/*
# Generate the OpenDKIM info:
echo "Configuring OpenDKIM..."
grep -q "$domain" /etc/postfix/dkim/keytable 2>/dev/null ||
echo "$subdom._domainkey.$domain $domain:mail:/etc/postfix/dkim/mail.private" >> /etc/postfix/dkim/keytable
echo "$subdom._domainkey.$domain $domain:$subdom:/etc/postfix/dkim/$subdom.private" >> /etc/postfix/dkim/keytable

grep -q "$domain" /etc/postfix/dkim/signingtable 2>/dev/null ||
echo "*@$domain $subdom._domainkey.$domain" >> /etc/postfix/dkim/signingtable
@@ -291,7 +304,6 @@ $dmarcentry
$spfentry" > "$HOME/dns_emailwizard"

echo "

_ _
| \ | | _____ ___
| \| |/ _ \ \ /\ / (_)


正在加载...
取消
保存