A few months ago, I switched from Gmail to Fastmail. So far I've been quite happy about it, they provide great service and you can use your own domain for 40$ per year. As a bonus, the company is owned by the employees, always a good thing.
If you want to be able to send emails from your Fastmail account via commandline, the easiest thing is to install SSMTP, a simple send-only sendmail emulator.
First, you should create a separate password in your account settings ("Advanced" → "Alternative Logins"). Choose "Regular" as login type and choose a password (ideally very long but without any special characters in it, to avoid parsing problems).
Then use the following configuration for your /etc/ssmtp/ssmtp.conf file. The configuration assumes that firstname.lastname@example.org is your Fastmail account login and email@example.com is your primary email address. If you don't use a custom domain, just use your regular Fastmail address in both places.
# /etc/ssmtp.conf -- a config file for sSMTP sendmail. # The user that gets all mail for userids less than 1000. If blank, address # rewriting is disabled. Rootfirstname.lastname@example.org # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com Mailhub=mail.messagingengine.com:465 # TLS Config UseTLS=YES UseSTARTTLS=NO # Where will the mail seem to come from? RewriteDomain=example.com # The full hostname Hostname=example.com # Username and password AuthUseremail@example.com AuthPass=your-long-password AuthMethod=PLAIN
Make sure to lock down the permissions of the config file, as it contains your password in plaintext:
sudo chown root:mail /etc/ssmtp/ssmtp.conf sudo chmod 640 /etc/ssmtp/ssmtp.conf
Add yourself to the mail group if you haven't already:
sudo usermod -a -G mail <local-username>
Possibly you have to logout and login again for the group permissions to work properly. You can now test whether sending email works:
echo "Testing SSMTP." | mail -s 'SSMTP Test' firstname.lastname@example.org