Setting up mail client on Arch Linux

I want to use command line mail client on the basic installation of Arch Linux, either mail or mutt or some other utility. I read that these are only mail clients means along with them we have to also install mail transfer agents. I tried to configure exim but that did not work out. Is there any other utility which can be easily configured and how to configure it ?


Postfix is quite easy to configure, especially for relaying through a "smarthost" (Gmail or ISP or whatever).


Configuring Postfix for Gmail:

  1. Update /etc/postfix/main.cf:

    compatibility_level = 2
    inet_interfaces = loopback-only
    relayhost = [smtp.gmail.com]:587
    # NOTE: the CAfile/CApath is distro-dependent!
    smtp_tls_CApath = /etc/ssl/certs
    smtp_tls_loglevel = 1
    smtp_tls_security_level = verify
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    
  2. Create /etc/postfix/sasl_passwd:

    [smtp.gmail.com]:587     [email protected]:JoesSekritPassword
    
  3. Run as root:

    postmap /etc/postfix/sasl_passwd
    chmod 640 /etc/postfix/sasl_passwd*
    chgrp postfix /etc/postfix/sasl_passwd*
    
  4. Tell Postfix to reload configuration:

    postfix reload
    

Exim is not bad either, as long as you ignore all the Debian-specific tutorials and their macros nonsense.

There also are msmtp and esmtp, which can only use a smarthost and so don't need to be run as a daemon. They also are much easier to configure, especially for multi-user environments.


If you are looking for the mail command, make sure you get either heirloom-mailx or GNU mailutils. (The classic bsd-mailx works, but it lacks many features such as Maildir or MIME support.) I still prefer mutt, though.


There are three things you need for basic email:

  • a program to format RFC 822 email that you are about to send
  • a program to send (RFC 822) formatted emails to your mail relay/submission system over SMTP (mail submission agent — MSA, or mail transfer agent — MTA)
  • a program to access your remote mailbox for things like remotely saved drafts, your inbox, etc. by using IMAP, POP, SMAP, rsyncing to a local mbox or maildir, or even just using sshfs to make the said mbox or maildir available on the filesystem (mail user agent — MUA, usually bundles the first component)

If you see the term 'mail delivery agent' (MDA), ignore it. That's a server-side program program for those creating their own service.

You likely already have the MUA (mutt, mailx, alpine, etc.), as well as the third component. The MSA likely is also built into the same program that is your MUA. Take a look at the following.

  • For example, for, the offical Arch Linux mutt package, in the simplest configuration (see muttrc(5)):

    # MUA part
    set folder = "imaps://[email protected]" # shortcut so that I can use relative
                                       # names for $spoolfile, etc.
    set spoolfile = "=INBOX"
    set record = "=Sent Messages"
    set postponed = "=Drafts"
    
    set from = "[email protected]"
    
    # MSA/MTA part
    set smtp_url = "smtp://[email protected]" # or `[email protected]@example.com`
                                            # if the server requires a fully
                                            # qualified user name, say because it
                                            # serves multiple domains
    
  • I've never used alpine but the Arch Wiki has a page on it.

  • For mailx (heirloom-mailx package, I believe the following ~/.mailrc (see mailx(1)) will do. Use mailx -A example.com to tell mailx to use that account.

    account example.com {
        set folder=imaps://[email protected]
        set imap-auth=login
        set record=+Sent
            set 
    
        set smtp=example.com
        set smtp-auth=plain # or whatever your server uses
        set smtp-auth-user=foo
    
        set from="[email protected] (Foo Bar)"
        set hostname=example.com
    }
    

Now, read on if you still want to use the traditional standalone MTA method. Since most traditional MUAs like mutt or mailx can use the sendmail interface (i.e., they just pipe mail to the sendmail binary, and you're only sending mail, not setting up a full-blown mail server, use the Dragonfly Mail Agent, rather than downloading a full server (like Postfix or sendmail). It's in the AUR. It just works and is only running when you actually send mail (i.e., it's not a deamon). It provides a wrapper binary at /usr/bin/sendmail. There's no configuration, assuming you're using an open relay. If you are using a relay that requires SMTP AUTH (you may often hear the term SASL, which is partially accurate), you can do something like what follows:

File /etc/dma/auth.conf:

some user|some mail relay or submission system:password

File /etc/dma/dma.conf (in addition to what is already in there by default):

SMARTHOST=hostname or IP address of smarthost or submission system or mail relay

You may have to configure your MUAs accordingly though. If I recall correctly, mailx and mutt need no additional configuration.