Friday, December 26, 2014

Implementing SSMTP to send email via command line

SSMTP is a program which delivers email from a local computer to a configured mailhost (mailhub). It is not a mail server (like feature-rich mail server sendmail) and it does not receive mail, expand aliases or manage a queue. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an external email address. Check for more information.

1. Remove sees and postfix (if it is currently installed on your system)

pacman -Rnd sees postfix

2. Install ssmtp

pacman -S ssmtp

3. Configure ssmtp

vim /etc/ssmtp/ssmtp.conf

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
# The person who gets all mail for userids < 1000
# Username/Password

4. Check permission
chmod 640 /etc/ssmtp/ssmtp.conf
chown root:mail /etc/ssmtp/ssmtp.conf

5. Users who can send mail
gpasswd -a mmara mail

6. Check your Google Less secure apps settings

7. Send test mail

echo test | mail -v -s "HELLO WORLD"

That's it!

No comments: