How to send emails to an SMTP server using the command line under FreeBSD

June 2013.
FreeBSD's native mail command cannot send emails through an SMTP server using a standard TCP connection. I guess it only uses sendmail.

The solution is to install heirloom-mailx, which is an alternate mailx command.


cd /usr/ports/mail/heirloom-mailx && make install clean


echo 'Some super relevant information' | /usr/local/bin/mailx -s 'One relevant subject' -S smtp=

Be careful of the fact that the original mailx command is not replaced (/usr/bin/mailx).