Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

SSMTP is no longer developed, but the two best options I found so far are SSMTP and MSMTP. 

MSMTP is still developed and is good at forwarding e-mails TO:ROOT onto user@domain.com

BUT MSMTP doesn't support the "mail -s" command, which everybody knows. 

SMSTP supports masking the FROM:ROOT = FROM:user@domain.com, but doesn't use /etc/aliases to forward on roots e-mail. 

CentOS is in the works!

The choice is yours!

sudo su

Ubuntu :

apt-get update
apt-get install -y msmtp msmtp-mta
nano /etc/msmtprc

##~~/etc/msmtprc

# Set default values for all following accounts.
defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        /var/log/msmtp.log
aliases        /etc/aliases


# Gmail
account        GMail
host           smtp.gmail.com
port           587
from           freesoftwareservers@gmail.com
user           freesoftwareservers
password       PASSWORD

# Comcast
account	       Comcast
# Residential
#host          smtp.comcast.net
# Business
#host	       smtp.hmc1.comcast.net
port           587
from           user@domain.com
user           user@domain.com
password       PASSWORD

# GoDaddy
account	       GoDaddy
host           smtpout.secureserver.net
tls_starttls   off
port           465
from           user@domain.com
user           user@domain.com
password       PASSWORD

# PLEASE SET THIS LINE
account default : GMail
chmod 600 /etc/msmtprc
nano /etc/aliases && newaliases

##~~/etc/aliases

# Example aliases file  
# Send root to Joe and Jane
#root: joe_smith@example.com, jane_chang@example.com
# Send everything else to admin
#default: admin@domain.example
# Send cron to Mark
#cron: mark_jones@example.com
#############################
root : freesoftwareservers@gmail.com
echo "Testing MSMTP" | msmtp root

Debug Testing :

http://websistent.com/msmtp-cron/

nano /etc/aliases && newaliases
echo "From: root \
To: Rec \
Subject: Hello World \
\
This is the email body" | sudo sendmail -d -t root

Create a cron job which echos some text which causes an email to be sent.

crontab -e
* * * * *   echo "A message from Cron"

Have a look at your syslog or messages file to know what is happening

tail -f /var/log/syslog

Make sure to remove the cron job immediately else an email will be triggered every minute and your Email Service provider might suspend your account.

 

NOTE: This didn't work for me, but It may work for you! - I'm still testing ATM

Use Mail Command :

sudo apt-get install -y heirloom-mailx

OR

sudo apt-get install -y s-nail
cat << EOL >/etc/mail.rc
set      sendmail=/usr/bin/msmtp
EOL
cat << EOL >/etc/msmtprc
aliases  /etc/aliases
EOL
echo "Hello, World" | mail -s "My email check-ROOT" root
echo "Hello, World" | mail -s "My email check" USER@DOMAIN.COM
  • No labels