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've had a look on Google and the man pages for mail, but I can't figure out how to set it up. All I want to do is set up my email address so that I can send email via the terminal. How do I do that?

share|improve this question

4 Answers 4

On many systems you will find a mailx command which can be used to send email. This may be a link to the mail command, but changes the behavior of the command. As other have noted, this assumes you have a MTA (Mail Transfer Agent) configured on your server. It can be used interactively using a command like:

mailx -s "This is a message" user@example.com
This is a message
.

Or with a pipe to send the output of a command:

cat myfile.txt | mailx -s "This is the file" user@example.com

Running it as mailx -h should give you usage instructions.

share|improve this answer

If you're not bound to the mail command, nail offers a similar interface but can send mail using SMTP.

share|improve this answer

Traditionally, Unix mail programs, including mail, rely on a MTA (Mail Transfer Agent) to do the actual transmission. For personal use, msmtp will be easiest to set up – it can only send mail, not receive, and allows user-specific configuration.

Install msmtp, then add your Gmail account into ~/.msmtprc:

defaults
    tls on
    # the path below may need to be adjusted
    tls_trust_file /etc/ssl/certs/ca-certificates.crt

account gmail
    from youraddress@gmail.com
    host smtp.gmail.com
    port 587
    auth plain
    user youraddress@gmail.com

account default : gmail

Now tell mail to use msmtp, by editing ~/.mailrc:

set sendmail="/usr/bin/msmtp"

(If this does not work, run ln -s /usr/bin/msmtp /usr/sbin/sendmail as root.)

Finally, if you want mail/msmtp to remember your Gmail password, it goes to ~/.netrc:

machine smtp.gmail.com
    login youraddress@gmail.com
    password "your password here"
share|improve this answer

Unless your system admin has already set up the mail system, you must configure a Mail Transfer Agent. That is sendmail traditionally, modern systems use postfix or exim4.

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.