I found sSMTP very simple to use.
In Debian based systems:
apt-get install ssmtp
Then edit the configuration file in /etc/ssmtp/ssmtp.conf
A sample configuration to use your gmail for sending e-mails:
# root is the person who gets all mail for userids < 1000 email@example.com # Here is the gmail configuration (or change it to your private smtp server) mailhub=smtp.gmail.com:587 AuthUserfirstname.lastname@example.org AuthPass=yourGmailPass UseTLS=YES UseSTARTTLS=YES
Note: Make sure the “mail” command is present in your system. mailutils package should provide this one in Debian based systems.
Update: There are people (and bug reports for different Linux distributions) reporting that sSMTP will not accept passwords with a ‘space’ or ‘#’ character. If sSMTP is not working for you, this may be the case.
- Add the IP for your external mail-relay to
/etc/hostsand add an alias mailrelay to it.
Modify the postfix configuration:
relayhost = [mailrelay] smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth smtp_sasl_security_options = noanonymous
Convert into hash-format
No need to say that only root should be able to read this…
mailx supports setting the smtp server on the CLI…
echo "message" | mailx -S smtp=$smtphost:$smtpport -s "subject line" -v email@example.com
Nothing needs to be installed, provided your smtp server lets you send un-authenticated mail.
There is no one answer that sets the smtp server for all the bits of software you might have on your Linux box. Each email client can configure a SMTP server.