This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| computing:mailclient [2026/04/08 19:28] – oemb1905 | computing:mailclient [2026/04/19 19:31] (current) – oemb1905 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Use this for personal machines behind someone else's LAN. It turns exim into a MUA instead of a MTA. That is, tt uses your remote self-hosted smtp instead of sending directly. | + | # 1. Main configuration |
| < | < | ||
| - | sudo apt install exim4 | + | cat << ' |
| - | sudo nano / | + | dc_eximconfig_configtype=' |
| - | dc_eximconfig_configtype=' | + | dc_smarthost=' |
| - | dc_smarthost=' | + | |
| dc_local_interfaces=' | dc_local_interfaces=' | ||
| dc_other_hostnames='' | dc_other_hostnames='' | ||
| Line 12: | Line 10: | ||
| dc_minimaldns=' | dc_minimaldns=' | ||
| dc_hide_mailname=' | dc_hide_mailname=' | ||
| - | #just in case | + | dc_localdelivery=' |
| - | dc_localdelivery=' | + | EOF |
| + | </ | ||
| - | sudo nano /etc/exim4/passwd.client | + | Local delivery is there as a placeholder but/and is ignored as per the localmacros entry below. It is harmless and in some cases I enable it and remove the other entry, |
| - | mail.domain.com: | + | |
| - | *:user:password | + | |
| - | sudo chown root:Debian-exim | + | * [[https://manpages.debian.org/jessie/exim4-config/update-exim4.conf.8.en.html |Man Pages Examples]] |
| - | sudo chmod 640 /etc/exim4/passwd.client | + | |
| - | #setup headers | + | Despite formatting it as the man pages and ncurses installer suggest, e.g., '' |
| - | sudo nano / | + | |
| - | sexa: remote@haacksnetworking.org | + | |
| - | root: remote@haacksnetworking.org | + | |
| - | *: remote@haacksnetworking.org | + | |
| - | #calm tls | + | |
| - | sudo nano / | + | # 2. Local macros |
| + | < | ||
| + | cat << ' | ||
| MAIN_TLS_ADVERTISE_HOSTS = | MAIN_TLS_ADVERTISE_HOSTS = | ||
| REMOTE_SMTP_SMARTHOST_HOSTS_REQUIRE_TLS = * | REMOTE_SMTP_SMARTHOST_HOSTS_REQUIRE_TLS = * | ||
| - | MAIN_HARDCODE_PRIMARY_HOSTNAME = domain.com | ||
| MAIN_LOCAL_DOMAINS = | MAIN_LOCAL_DOMAINS = | ||
| - | #disable_ipv6=true | + | disable_ipv6 = true |
| + | EOF | ||
| + | </ | ||
| - | sudo update-exim4.conf | + | This block has a lot. First, it requires TLS whether the server does or not. Secondly, it stops attempts at local delivery, i.e., if I had a cronjob trying to email a report to user@haacksnetworking.org or user@net.haacksnetworking.org, |
| - | sudo systemctl restart | + | |
| - | + | ||
| - | echo "Test after permission fix" | mail -s "Exim4 test 2" oemb1905@jonathanhaack.com | + | |
| - | sudo tail -f / | + | |
| + | # 3. Password file | ||
| + | < | ||
| + | cat << ' | ||
| + | mail.haacksnetworking.org: | ||
| + | *:net:pass | ||
| + | EOF | ||
| </ | </ | ||
| - | Here's a copy pastable version: | + | Pretty self-explanatory. Replace |
| + | # 4. Email address rewriting | ||
| < | < | ||
| - | sudo apt install exim4 | + | cat << ' |
| - | cat << ' | + | sexa: net@haacksnetworking.org |
| - | dc_eximconfig_configtype=' | + | root: net@haacksnetworking.org |
| - | dc_smarthost=' | + | *: net@haacksnetworking.org |
| - | dc_local_interfaces=' | + | |
| - | dc_other_hostnames='' | + | |
| - | dc_readhost=' | + | |
| - | dc_relay_domains='' | + | |
| - | dc_minimaldns=' | + | |
| - | dc_hide_mailname=' | + | |
| - | dc_localdelivery=' | + | |
| EOF | EOF | ||
| + | </ | ||
| - | cat << 'EOF' | sudo tee /etc/exim4/ | + | This re-writes the headers so that system and/or cronjob emails originating from the client match the remote smtp user credentials and domain. Without this, exim4 would use the system email as the envelope-from instead of the remote server's. This is essential for emails to arrive at Gmail, Microsoft, etc., without issue. |
| - | mail.domain.com: | + | |
| - | *: | + | # 5. Set mailname and hostname |
| - | EOF | + | < |
| + | echo " | ||
| + | echo "net.outsidebox.vip" | sudo tee / | ||
| + | </ | ||
| + | Make sure alias and fqdn are also specified properly in ''/ | ||
| + | |||
| + | # 6. Fix permissions and apply | ||
| + | < | ||
| sudo chown root: | sudo chown root: | ||
| sudo chmod 640 / | sudo chmod 640 / | ||
| - | |||
| - | sudo cat << EOF > / | ||
| - | sexa: remote@haacksnetworking.org | ||
| - | root: remote@haacksnetworking.org | ||
| - | *: remote@haacksnetworking.org | ||
| - | EOF | ||
| - | |||
| - | cat << ' | ||
| - | MAIN_TLS_ADVERTISE_HOSTS = | ||
| - | REMOTE_SMTP_SMARTHOST_HOSTS_REQUIRE_TLS = * | ||
| - | MAIN_HARDCODE_PRIMARY_HOSTNAME = domain.com | ||
| - | MAIN_LOCAL_DOMAINS = | ||
| - | # | ||
| - | EOF | ||
| sudo update-exim4.conf | sudo update-exim4.conf | ||
| sudo systemctl restart exim4 | sudo systemctl restart exim4 | ||
| - | |||
| - | echo "Exim4 configured and restarted." | ||
| - | echo "Test with:" | ||
| - | echo 'echo "Test from $(hostname)" | ||
| </ | </ | ||
| - | We turned off local delivery above so now all we need to do is set the hostname | + | Set permissions on the credentials |
| - | echo " | + | # 7. Configure the **remote mailserver** to accept email from the subdomain and/or other IP of the client: |
| - | echo "haacksnetworking.org" | sudo tee / | + | < |
| - | + | nano /etc/postfix/ | |
| - | Then, in ''/ | + | mydestination = mail.haacksnetworking.org, |
| - | + | | |
| - | 127.0.1.1 | + | mail.haacksnetworking.org, |
| - | + | node0.otherdomain.org, #accept system | |
| - | Send a few test emails to external domains (external to mail server) and to local users (local on the client): | + | node1.otherdomain.com, #accept system |
| - | + | localhost.haacksnetworking.org, | |
| - | echo " | + | |
| - | echo " | + | sudo systemctl restart postfix |
| - | + | </ | |
| - | === Alias Test === | + | |
| - | Both will work ... and here's how and why. In the first case, you send from the client to root, and exim sends the email (via the above configuration) | + | |
| - | + | ||
| - | === External Test === | + | |
| + | We need to adjust the remote email server. This is because, as mentioned above, system emails default to '' | ||
| - | --- // | + | --- // |