Add information on how to use implicit TLS

This commit is contained in:
Tommy Nguyen
2019-02-25 04:49:33 -05:00
parent cc5edcae1c
commit 942c1f4d0f

View File

@@ -2087,8 +2087,9 @@ You can use any Gmail account but I recommend you create one specific for this s
- `mail` configured to send e-mails from your server using [Gmail](https://mail.google.com/) - `mail` configured to send e-mails from your server using [Gmail](https://mail.google.com/)
#### References #### References
- https://wiki.debian.org/Exim
- https://php.quicoto.com/setup-exim4-to-use-gmail-in-ubuntu/ - https://wiki.debian.org/GmailAndExim4
- https://www.exim.org/exim-html-current/doc/html/spec_html/ch-encrypted_smtp_connections_using_tlsssl.html
#### Steps #### Steps
@@ -2112,14 +2113,16 @@ You can use any Gmail account but I recommend you create one specific for this s
|Prompt|Answer| |Prompt|Answer|
|--:|--| |--:|--|
|General type of mail configuration|`mail sent by smarthost; no local mail`| |General type of mail configuration|`mail sent by smarthost; no local mail`|
|System mail name|(default)| |System mail name|`Your FQDN or localhost`|
|IP-addresses to listen on for incoming SMTP connections|`127.0.0.1`| |IP-addresses to listen on for incoming SMTP connections|`127.0.0.1`|
|Other destinations for which mail is accepted|(default)| |Other destinations for which mail is accepted|(default)|
|Visible domain name for local users|(default)| |Visible domain name for local users|`Your FQDN or localhost`|
|IP address or host name of the outgoing smarthost|`smtp.gmail.com::587`| |IP address or host name of the outgoing smarthost|`smtp.gmail.com::465`|
|Keep number of DNS-queries minimal (Dial-on-Demand)?|`No`| |Keep number of DNS-queries minimal (Dial-on-Demand)?|`No`|
|Split configuration into small files?|`No`| |Split configuration into small files?|`No`|
If you prefer to use `STARTTLS`, then choose port `587`.
1. Make a backup of `/etc/exim4/passwd.client`: 1. Make a backup of `/etc/exim4/passwd.client`:
``` bash ``` bash
@@ -2132,6 +2135,8 @@ You can use any Gmail account but I recommend you create one specific for this s
*.google.com:yourAccount@gmail.com:yourPassword *.google.com:yourAccount@gmail.com:yourPassword
``` ```
Always check `host smtp.gmail.com` for the most up-to-date domains to list.
Replace `yourAccount@gmail.com` and `yourPassword` with your details. If you have 2FA/MFA enabled on your Gmail then you'll need to create and use an app password. Replace `yourAccount@gmail.com` and `yourPassword` with your details. If you have 2FA/MFA enabled on your Gmail then you'll need to create and use an app password.
1. This file has your Gmail password so we need to lock it down: 1. This file has your Gmail password so we need to lock it down:
@@ -2141,9 +2146,47 @@ You can use any Gmail account but I recommend you create one specific for this s
sudo chmod 640 /etc/exim4/passwd.client sudo chmod 640 /etc/exim4/passwd.client
``` ```
1. The following instructions only apply if you choose implicit TLS (port 465) instead of `STARTTLS`. Skip to "restart `exim4`" if you are not using implicit TLS.
You need a TLS certificate. You can either use [Let's Encrypt](https://letsencrypt.org/), the `openssl` command or just let Exim generate it for you.
``` bash
sudo bash /usr/share/doc/exim4-base/examples/exim-gencert
```
1. Now instruct Exim4 to use TLS and port 465:
In `/etc/exim4/exim4.conf.template`, CTRL+F for `30_exim4-config_remote_smtp_smarthost` then add `protocol=smtps`.
In `/etc/exim4/exim4.conf.localmacros`, add:
```
MAIN_TLS_ENABLE = 1
REMOTE_SMTP_SMARTHOST_HOSTS_REQUIRE_TLS = *
TLS_ON_CONNECT_PORTS = 465
REQUIRE_PROTOCOL = smtps
```
In `/etc/exim4/exim4.conf.template`, CTRL+F for `REMOTE_SMTP_SMARTHOST_HOSTS_REQUIRE_TLS` and after the `ifdef` block add:
```
.ifdef REQUIRE_PROTOCOL
protocol = REQUIRE_PROTOCOL
.endif
```
CTRL+F for `MAIN_TLS_ENABLE` and after the `ifdef` block add:
```
.ifdef TLS_ON_CONNECT_PORTS
tls_on_connect_ports = TLS_ON_CONNECT_PORTS
.endif
```
1. Restart `exim4`: 1. Restart `exim4`:
``` bash ``` bash
sudo update-exim4.conf
sudo service exim4 restart sudo service exim4 restart
``` ```
@@ -2157,6 +2200,13 @@ You can use any Gmail account but I recommend you create one specific for this s
You'll need to add all the local accounts that exist on your server. You'll need to add all the local accounts that exist on your server.
1. Test your setup:
```
echo "test" | mail -s "Test" email@example.com
sudo tail /var/log/exim4/mainlog
```
([Table of Contents](#table-of-contents)) ([Table of Contents](#table-of-contents))
### Separate `iptables` Log File ### Separate `iptables` Log File