I'm assuming that you are using a Debian based derivative given that you mentioned apt-get in your question.
This can be done fairly simply using the exim4 mail package. A simple
apt-get install exim4 exim4-config
Will install everything that you need to send mail via smtp. Note you need to be root or use sudo for the apt-get command to work.
During the install the exim4-config package setup will ask you a number of questions that will let you configure things appropriately.
You should probably select the mail sent by smarthost; no local mail option and give it details of your outgoing mail provider. It is also possible to send mail directly as an internet site; mail is sent and received directly using SMTP but that can have issues with your internet providers so you are best to start off using a smarthost.
If you need to tweak your configuration you can use
dpkg-reconfigure -plow exim4-config
I'm guessing that your outgoing mail provider will require your machine to authenticate before it allows sending of mail. In that case you need to add an entry into /etc/exim4/passwd.client . The format is quite simple each takes the format of servername:login:password and is documented in
The latter also tells you how to configure other settings files. It will likely be of interest to setup /etc/email-addresses to ensure that when you send email as a specific user it gets sent via your ISP as your real outgoing address