Based in part on: https://www.debarbora.com/freebsd-10-1-setup-ssmtp-for-outgoing-mail/
Edit /etc/rc.conf
to add:
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
service sendmail stop
root@cancer-1050740:~ # pkg install -y ssmtp
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
ssmtp: 2.64_3
Number of packages to be installed: 1
19 KiB to be downloaded.
[1/1] Fetching ssmtp-2.64_3.txz: 100% 19 KiB 19.7kB/s 00:01
Checking integrity... done (0 conflicting)
[1/1] Installing ssmtp-2.64_3...
===> Creating groups.
Creating group 'ssmtp' with gid '916'.
[1/1] Extracting ssmtp-2.64_3: 100%
Message from ssmtp-2.64_3:
sSMTP has been installed successfully.
To replace sendmail with ssmtp type "make replace" or change
your /etc/mail/mailer.conf to:
sendmail /usr/local/sbin/ssmtp
send-mail /usr/local/sbin/ssmtp
mailq /usr/local/sbin/ssmtp
newaliases /usr/local/sbin/ssmtp
hoststat /usr/bin/true
purgestat /usr/bin/true
However, before you can use the program, you should copy the files
"revaliases.sample" and "ssmtp.conf.sample" in /usr/local/etc/ssmtp
to "revaliases" and "ssmtp.conf" respectively and edit them to suit
your needs.
A sample configuration with comments is in /usr/local/etc/ssmtp/ssmtp.conf.sample
.
Create a new /usr/local/etc/ssmtp/ssmtp.conf
with the following contents:
root=postmaster
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=<SMTP host IP or hostname>:587
AuthUser=<userid for authentication>
AuthPass=<user credentials for authentication>
FromLineOverride=NO
Hostname=_HOSTNAME_ (or whatever)
RewriteDomain=<domain where the mail should appear to come from>
useTLS=YES <- may be required for some SMTP providers instead of useSTARTTLS
useSTARTTLS=YES <- Confirmed to work with Amazon Simple Email Service (SES)
Then change permissions:
chmod o-r ssmtp.conf
A sample configuration with comments is in /usr/local/etc/ssmtp/revaliases.sample
.
Create a new /usr/local/etc/ssmtp/revaliases
with the following contents:
root:[email protected]:SMTP.hostname.com:587
(or :25 if not using TLS)
And then change permissions:
chmod o-r revaliases
chpass
Replace Charlie &
in the Full Name:
field with whatever.
After this step, outgoing mail will be enabled.
Replace /etc/mail/mailer.conf
(as suggested after package installation) with:
sendmail /usr/local/sbin/ssmtp
send-mail /usr/local/sbin/ssmtp
mailq /usr/local/sbin/ssmtp
newaliases /usr/local/sbin/ssmtp
hoststat /usr/bin/true
purgestat /usr/bin/true
mail -v -s "cmdline test" [email protected]
(use .
on empty line to end)
Open /etc/defaults/periodic.conf
and search for lines
Include double quotes, use commas between email adresses, and do not include local account names.