Setup for sending mail via Mutt

Richard Akintola <[email protected]> Tue, 1 Apr 2025 14:11:31 +0100
Newsgroups dev.linux.lists.outreachy
Message-ID <[email protected]>
The following assumes that you have installed Esmtp or Exim4 (default on Debian)
and you have generated password using App Password (for Gmail)

Configure Esmtp 
1. Added the following to ~/.esmtp file
identity "[email protected]"
hostname smtp.gmail.com:587
username "[email protected]"
password "passwordGeneratedByAppPassword"
starttls required

2. Make sendmail point to esmtp using the command
sudo update-alternatives --install /usr/sbin/sendmail sendmail /usr/bin/esmtp 50

3. Test if esmtp can send mails
echo "Testing email via esmtp" | /usr/sbin/sendmail -v [email protected]

4. Add the following to ~/.muttrc file
set sendmail="/usr/bin/esmtp"
set envelope_from=yes
set from="My Name <[email protected]>"
set use_from=yes
set edit_headers=yes

5. Setup Done


Configure Exim4 (default mail transfer agent - MTA on Debian)
1. Make sendmail point to exim4 using the command
sudo update-alternatives --install /usr/sbin/sendmail sendmail /usr/sbin/exim4 100

2. Run the command below to add gmail and password to exim4 in the format below
sudo vi /etc/exim4/passwd.client

smtp.gmail.com:[email protected]:passwordGeneratedByAppPassword

3. Add the following configuration to update-exim4.conf.conf via sudo
 e.g sudo vi /etc/exim4/update-exim4.conf.conf

dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1; ::1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

3. Test if Exim4 can send mails
echo "Testing email via Exim4" | /usr/sbin/sendmail -v [email protected]

4. Add the following to ~/.muttrc
set sendmail="/usr/sbin/exim4"
set use_from=yes
set realname="Your Name"
set from="[email protected]"
set envelope_from=yes

5. Setup Done.