sSMTP Configuration

Discussion and Technical Support for general software applications and utilities including OS related issues.
Post Reply
mt_subnet
Member
Member
Posts: 2
Joined: May 13th, 2017, 10:11 am

sSMTP Configuration

Post by mt_subnet »

I realise that this is not necessarily the best forum to ask this question but since what little I know of the inner workings of things Linux all stems from the marvelous little tutorials to be found at havetheknowhow it always feels like home, a warm and friendly place.
I am having a little local difficulty with sSMTP. I originally set it up from one of those tutorials which was in line with all the others I have seen but recently I have had two problems.
Firstly my samba server suffered a panic attack and started sending out emails, as you can see from the log entry...........

May 7 09:27:15 the-box sSMTP[19627]: Sent mail for root@usa.net (221 Goodbye) uid=0 username=root outbytes=763

My email provider usa.net were not best pleased to see me hijacking their "root" user. Sorted the samba problem then had a look at the sSMPT settings and made changes.....................

Code: Select all

#rewriteDomain=usa.net - Commented out
#hostname=pauldmallett@usa.net - Changed
hostname=the-box
#FromLineOverride=YES - Changed
FromLineOverride=NO
Possibly over kill and I am not sure what the side effects will be.
The next problem was in the apache2/php/cron area, I am playing around with some local sites Wordpress, Magento and others anyway....

May 9 17:22:05 the-box sSMTP[18062]: Sent mail for root@usa.net (221 Goodbye) uid=1000 username=j-dow outbytes=811

BAE Systems who now own usa@net declared a national emergency and shut down my email account {and the National Heath Service} these were actually addressed to j-dow@usa.net a non existent account.
I made some changes to both php.ini files......

Code: Select all

[mail function]
;SMTP = localhost
;smtp_port = 25
sendmail_path = /usr/sbin/ssmtp -t -i
mail.force_extra_parameters = -f <myemailname>@usa.net
I also added a parameter to cron

Code: Select all

MAILTO=pauldmallett@usa.net
I may or may not have got this sorted but I am uncertain about the settings in the ssmtp.conf file I do not want to block alerts altogether as it is only there for that purpose and not for personal email.
The other thing that occurs to me is that it would make sense for sSMTP set up instructions to contain additional instructions for php and cron. I am still puzzling over the best way to deal with samba, it may require an edit in the "panic" file as this is where the "root" user is invoked, changing it to <myemailname> would probably do it.
Anyway I was just hoping to kick it around while I decide where to look for something better than my best guess.
mt_subnet
Member
Member
Posts: 2
Joined: May 13th, 2017, 10:11 am

Re: sSMTP Configuration

Post by mt_subnet »

Hi, I have completed my research and in case it is of use I am posting my modified configuration. This designed to catch mail from samba panic attacks and cron job notifications on my headless media server, the fundamental change is the configuration of the revaliases file which resides alongside the ssmtp.conf file. This file uses names users to use specified email addresses and stops them from creating their own.

Code: Select all

sudo nano /etc/ssmtp/ssmtp.conf
EDIT FILE
-----------------------------------------------
#
#If active gives output for debugging  /var/log/syslog
Debug=YES
#CUSTOM "ssmtp.conf" FOR SERVERS
# Config file for sSMTP "sendmail"
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#EDIT CHANGE TO DESIRED EMAIL ADDRESS
#root=postmaster
root=mailusername@usa.net
#addlocalusername=

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#EDIT CHANGE TO DESIRED smtp SERVER
#mailhub=mail
mailhub=smtp.postoffice.net
#EDIT ADD "AuthUser" & PASSWORD & NEXT TWO LINES
AuthUser=mailusername//usa.net
AuthPass=< mymailpassword >
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
#EDIT COMMENT OUT IF REVALIASES FILE IS IN USE
#rewriteDomain=
#rewriteDomain=usa.net

# The full hostname
#EDIT ADD HOSTNAME OR EMAIL OR BLANK
hostname=my-box
#hostname=mailusername@usa.net

# Are users allowed to set their own From: address?
# EDIT "NO" IF REVALIASES FILE IS IN USE
FromLineOverride=NO
#FromLineOverride=YES
-----------------------------------------------------------
END EDIT SAVE
-----------------------------------------------------------
TO COMPLETE CONFIGURATION
REVALIASES - ADD LINE FOR EACH USERNAME THAT MAY INITIATE EMAILS 
CRON MAY & SAMBA DOES RUN AS ROOT REPORTS MAY BE ADDRESSED FROM "USER" OR "ROOT". 
SET USERS & ROOT EMAIL ADDRESS TO A VALID ADDRESS

sudo nano /etc/ssmtp/revaliases
#EDIT ADD FOR EACH USER - EMAIL:SMTP SERVER:PORT-IF-REQUIRED
root:mailusername@usa.net:smtp.postoffice.net
username:mailusername@usa.net:smtp.postoffice.net
#END EDIT SAVE
sudo chown root:mail /etc/ssmtp/ssmtp.conf
sudo chmod 775 /etc/ssmtp/ssmtp.conf
REVIEW MEMBERS OF GROUP "mail"
SET MAILTO VARIABLE IN ALL CRONTABS
sudo crontab -e
#EDIT
MAILTO=mailusername@usa.net
#EDIT END
SET MAIL IN PHP PROBABLY NOT NEEDED
sudo nano /etc/php5/apache2/php.ini
sudo nano /etc/php5/cli/php.ini
#EDIT
[mail function]
;SMTP = localhost
;smtp_port = 25
sendmail_path = /usr/sbin/ssmtp -t -i
mail.force_extra_parameters = -f mailusername@usa.net
#END EDIT SAVE
sudo service apache2 restart
Post Reply