How to set up mail in terminal to use email?

Solution 1:

If you only want to send emails, do this.

Install ssmtp with this command:

sudo apt-get install ssmtp

Open up the ssmtp configuration file with:

sudo vim /etc/ssmtp/ssmtp.conf

and edit the file so it looks like this:

[email protected]
mailhub=smtp.gmail.com:587
AuthUser=YOURUSERNAME
AuthPass=YOURPASSWORD
UseSTARTTLS=YES
UseTLS=YES
mailhub=smtp.gmail.com:587

The above is an example with gmail. You have to change the mailhub and root lines if you're not using gmail. (For yahoo mail change the mailhub line to mailhub=smtp.mail.yahoo.com:587)

After this is done you will be able to send mail like this:

echo "Test message" | mail -s "Test subject" [email protected]