The standard way to send an email from a shell script is the
mail command, which is provided by the
bsd-mailx package. To use it, you do something like:
echo 'This is the message.' | mail -s 'Subject line here' email@example.com
For more control, the standard way is the
sendmail command. The
mail command is actually just a wrapper that calls
sendmail with a correctly formatted email.
sendmail command is the standard Unix interface to the mail transport agent (MTA) on a Unix system. Traditionally, all Unix systems have one. But since they generally need configuring, neither Ubuntu desktop nor server install one by default. So you need to install an MTA yourself.
Postfix and Exim are probably the two most popular MTAs right now. Both are packaged well and work fairly easily out of the box. But they're full featured. They can be configured minimally, and the package helps you do this automatically, but the documentation you'll find online will generally assume that you have full MTA functionality configured (eg. mailboxes for incoming email and so forth).
If you just want to send outbound email, then nullmailer is a good choice. It is a minimal MTA designed to provide the standard
sendmail interface so everything up the stack will work fine, except it sends mail out only.
Postfix, Exim are all in main, so are well supported in Ubuntu. nullmailer is in universe, so is community supported only.
So to summarise:
Select and install an MTA. If just for outbound mail from shell scripts, then nullmailer is a good choice.
bsd-mailx package and then use
mail to send email from your shell script.