Is EC2 a VPS or Virtual Private Server? I assume this
Most linux distro's (like ubuntu) can run their own mail server. A common default one is postfix I believe. You can also use exim4 which has become more popular recently. Depending if you have a preference or going with whatever is default, they can often be configured with this command and going through its options.
dpkg-reconfigure mail-program
with mail-program being exim4-config, postfix or whatever.
There are a lot of guides for setting up mail-servers and much more complete then any quick guide I'd write here, so peruse them to your liking.
As for setting up smtp credentials, this is for a external server.
There are pro's and con's to hosting it yourself versus using a service and if you do host it yourself, be sure to check for error messages as emails may be rebounded by certain domains. google for example seems to connect over IPV6 and refuses connections without a valid reverse DNS lookup for IPV6 connections! (annoying - but makes sense). Using a exernal server will probably result in less of these issues but involves trusting a third party with potentially sensitive info of not only yourself but anyone using your site(s).
I do not use EC2 but use Debian as the installed server (one step up the ladder from Ubuntu) Personally , I use exim4 for outbound only mail. I don't regulate outbound traffic as I consider software installed on my server to be trustworthy and rather only regulate (strictly) incoming traffic.
Because of this, I do not need to modify any smtp settings in the flarum database.