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.

Install:

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

Use:

echo 'Some super relevant information' | /usr/local/bin/mailx -s 'One relevant subject' -S smtp=192.0.2.42 mailx@example.net

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