Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 ?

share|improve this question

4 Answers 4

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:

    relayhost = [smtp.gmail.com]:587
    smtp_tls_security_level = encrypt
    smtp_tls_CApath = /etc/ssl/certs
    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     joe@gmail.com: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.

share|improve this answer
    
Could you provide me the link to configure PostFix for Gmail? –  pineapple Jan 15 '11 at 18:28
    
@pineapple: See edited answer, or google postfix gmail. (Btw, it's "Postfix", not "PostFix.") –  grawity Jan 15 '11 at 21:17
    
I configured the Postfix as you mentioned. But when I send mails using mutt or sendmail,they show no error but I am not receiving any mails in gmail. I want to know how to check the status of mail whether it was delivered or not. Also using sendmail, I sent mail like this: sendmail <id> and then typed the body and pressed Ctrl D. Is this the correct way? When using mutt, it says mail sent. But when I open mutt for the first time,it says /var/spool/mail/root:No such file or directory I want to confirm that I only want to configure postfix for outgoing mails.I don want to fetch mails from gmail. –  pineapple Jan 16 '11 at 2:50
    
@pineapple: No, it's not the correct way to use sendmail -- it expects to be called from a mail client and given a full RFC-(2)822 message, incl. headers. You should use mail <addr> or mutt <addr> instead. // However, a good MTA will send the message anyway -- so please check the Postfix queue (mailq) and the system logs (sudo tail -f /var/log/mail.log) for any error messages. –  grawity Jan 16 '11 at 11:21
    
@grawity See the suggested edit, please review if that's correct or requires any additional comment. –  slhck Feb 28 '12 at 11:34

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://foo@example.com" # shortcut so that I can use relative
                                       # names for $spoolfile, etc.
    set spoolfile = "=INBOX"
    set record = "=Sent Messages"
    set postponed = "=Drafts"
    
    set from = "foo@example.com"
    
    # MSA/MTA part
    set smtp_url = "smtp://foo@example.com" # or `foo@example.com@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://foo@example.com
        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="foo@example.com (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.

share|improve this answer

I think Vmail is pretty good, although I don't believe we can shoot files around from within scripts... like my favorite trick of sending myself email notifications when a job is complete. But if you're just looking for a text-based front end for Gmail, this is it.

share|improve this answer

ssmtp is a very lightweight, easy-to-configure MTA.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.