If you want to receive status updates from your Debian GNU/Linux system in your inbox, you need to employ the help of a mail transfer agent (MTA).
Exim can be configured to use Fastmail as a smarthost and hence ensure the deliverability of your messages. In principle, these instructions should also be applicable to service providers other than Fastmail.
In the following example configuration, debian
is the hostname, bookworm
the local username and linus.torvalds@fastmail.com
the Fastmail username.
Step 1
Log into your Fastmail account and set up a new app password for SMTP authentication.
Step 2
Install the required packages from the Debian repository.
$ sudo apt-get install exim4-daemon-light
Step 3
Perform the initial configuration using debconf
.
$ sudo dpkg-reconfigure exim4-config
Selecting the type of configuration
Select the option for sending mail using a smarthost.
Mail server configuration General type of mail configuration: mail sent by smarthost; no local mail Ok
Setting the mail name
Set the system mail name. If you are setting up on a home network, you should use home.arpa
as the domain name.
Mail server configuration System mail name: debian.home.arpa Ok
Listening for incoming connections
Only accept connections from the localhost.
Mail Server configuration IP-addresses to listen on for incoming SMTP connections: 127.0.0.1 ; ::1 Ok
Other destinations
Mail Server configuration Other destinations for which mail is accepted: debian.home.arpa Ok
Visible domain name
Mail Server configuration Visible domain name for local users: debian.home.arpa Ok
Configuring the smarthost
Set the Fastmail SMTP server as the smarthost. Do not miss the double colon!
Mail Server configuration IP address or host name of the outgoing smarthost: smtp.fastmail.com::465 Ok
Minimising DNS-queries
Mail Server configuration Keep number of DNS-queries minimal (Dial-on-Demand)? No
Splitting configuration files
Opt to use a number of small files in /etc/exim4/conf.d/
instead of a single monolithic file in /etc/exim/
.
Mail Server configuration Split config/etc/exim/uration into small files? Yes
Step 4
Make changes to /etc/email-addresses
.
$ sudo nano /etc/email-addresses
Provide an outgoing email address for the user bookworm
.
# This is /etc/email-addresses. It is part of the exim package # # This file contains email addresses to use for outgoing mail. Any local # part not in here will be qualified by the system domain as normal. # # It should contain lines of the form: # #user: someone@isp.com #otheruser: someoneelse@anotherisp.com bookworm: linus.torvalds@fastmail.com
Step 5
Make changes to /etc/aliases
.
$ sudo nano /etc/aliases
Append the following line to send messages for the local user bookworm
to the Fastmail address linus.torvalds@fastmail.com
.
bookworm: linus.torvalds@fastmail.com
Step 6
Make changes to /etc/exim4/passwd.client
.
$ sudo nano /etc/exim4/passwd.client
Set the Fastmail server as the smarthost. Use the app password you set in Step 1.
# password file used when the local exim is authenticating to a remote # host as a client. # # see exim4_passwd_client(5) for more documentation # # Example: ### target.mail.server.example:login:password smtp.fastmail.com:linus.torvalds@fastmail.com:app password
Step 7
Generate a local certificate with the following command.
$ sudo bash /usr/share/doc/exim4-base/examples/exim-gencert
Provide your country code as well as server name.
Country Code (2 letters) [US]:your contry code State or Province Name (full name) []: Locality Name (eg, city) []: Organization Name (eg, company; recommended) []: Organizational Unit Name (eg, section) []: Server name (eg. ssl.domain.tld; required!!!) []:debian.home.arpa Email Address []:
Step 8
Modify the default by creating additional configuration files, taking extra care not to miss any punctuation.
MAIN_TLS_ENABLE
$ sudo -- bash -c "echo -e 'MAIN_TLS_ENABLE = yes\nREMOTE_SMTP_SMARTHOST_HOSTS_REQUIRE_TLS = *\nTLS_ON_CONNECT_PORTS = 465\nREQUIRE_PROTOCOL = smtps' >> /etc/exim4/conf.d/main/02_exim4-config_tlsoptions"
TLS_ON_CONNECT_PORTS
$ sudo -- bash -c "echo -e '.ifdef TLS_ON_CONNECT_PORTS\n tls_on_connect_ports = TLS_ON_CONNECT_PORTS\n.endif' >> /etc/exim4/conf.d/main/04_exim4-config_tlsoptions"
REQUIRE_PROTOCOL
$ sudo -- bash -c "echo -e '.ifdef REQUIRE_PROTOCOL\n protocol = REQUIRE_PROTOCOL\n.endif' >> /etc/exim4/conf.d/transport/31_exim4-config_remote_smtp_smarthost"
Step 9
Update aliases and restart the Exim service.
$ sudo -- bash -c "newaliases&&update-exim4.conf&&systemctl restart exim4"
Step 10
Test your configuration with the following command.
$ sudo echo "Test mail from exim4 on debian.home.arpa to the local root user and forwarded on to Fastmail" | mail -s "Test Exim" root
Check your Inbox, Linus!