# System emails without mail (WITHOUT_SENDMAIL=YES)



## freebuser (Feb 22, 2022)

Hi,
I have compiled FreeBSD without sendmail.
How do I replace system emails with SSMTP? Say for example periodic ?


----------



## SirDice (Feb 22, 2022)

Fix /etc/mail/mailer.conf as instructed by the pkg-message (`pkg info -D ssmtp`).


----------



## zirias@ (Feb 22, 2022)

Why not just use `dma`, which is in base as well? Works fine for me, I always install base without sendmail...


----------



## freebuser (Feb 22, 2022)

SirDice said:


> Fix /etc/mail/mailer.conf as instructed by the pkg-message (`pkg info -D ssmtp`).



I believe when I run make delete-old all mail related files got deleted if compiled with WITHOUT_SENDMAIL=YES.



Zirias said:


> Why not just use `dma`, which is in base as well? Works fine for me, I always install base without sendmail...


The issue is periodic call for mail.
Otherwise I can use ssmtp with a symlink for mail, but the arguments for mail in periodic appears to be incompatible with ssmtp.


----------



## SirDice (Feb 22, 2022)

freebuser said:


> I believe when I run make delete-old all mail related files got deleted if compiled with WITHOUT_SENDMAIL=YES.


No, not to my knowledge. You still have mailwrapper(8). 


```
WITHOUT_MAIL
             Do not build any mail support (MUA or MTA).  When set, it
             enforces these options:

             WITHOUT_DMAGENT
             WITHOUT_MAILWRAPPER
             WITHOUT_SENDMAIL

     WITHOUT_MAILWRAPPER
             Do not build the mailwrapper(8) MTA selector.
```


----------



## freebuser (Feb 23, 2022)

SirDice said:


> No, not to my knowledge. You still have mailwrapper(8).
> 
> 
> ```
> ...




```
make -C /usr/src/ delete-old DESTDIR=/..../jails/....
>>> Removing old files (only deletes safe to delete libs)
remove /..../jails/..../etc/mail/mailer.conf?
```


----------



## SirDice (Feb 23, 2022)

So you also have WITHOUT_MAIL? Or WITHOUT_MAILWRAPPER? Because those two would remove mailwrapper(8).


----------



## freebuser (Feb 23, 2022)

SirDice said:


> So you also have WITHOUT_MAIL? Or WITHOUT_MAILWRAPPER? Because those two would remove mailwrapper(8).



No, I only have WITHOUT_SENDMAIL. But when I delete-old mail and rmail got deleted along with mailer.conf.
Not sure what mailwrapper does, my issue is periodic script calls for 'mail' and error out as mail is not there anymore.
I am reluctant to edit any system files and upset future updates.
Soft link for ssmtp as mail does not work either as the arguments called in periodic script does not relate to ssmtp.


----------



## SirDice (Feb 23, 2022)

freebuser said:


> No, I only have WITHOUT_SENDMAIL. But when I delete-old mail and rmail got deleted along with mailer.conf.


That shouldn't happen. It should only be removed if you have WITHOUT_MAILWRAPPER. But perhaps only /etc/mail/mailer.conf is removed, try just creating it with the information from `pkg info -D ssmtp`.




freebuser said:


> Not sure what mailwrapper does, my issue is periodic script calls for 'mail' and error out as mail is not there anymore.


That is exactly the function of mailwrapper(8) (read the man page).



freebuser said:


> I am reluctant to edit any system files and upset future updates.


This file is meant to be edited.



```
root@armitage:~ # pkg info -x ssmtp
ssmtp-2.64_7
root@armitage:~ # cat /etc/mail/mailer.conf
#
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
```
periodic(8) mail works on my system.


----------



## mer (Feb 23, 2022)

If you don't mind physically looking at log files, periodic can be setup to send output to files instead of emails.
This is what I put in my /etc/periodic.conf

```
daily_output="/var/log/daily.log"
daily_status_security_output="/var/log/dailysecurity.log"
daily_status_network_usedns="NO"
daily_status_named_usedns="NO"
daily_clean_tmps_enable="YES"
daily_status_ntpd_enable="NO"
daily_status_zfs_enable="YES"
daily_status_smart_enable="YES"
daily_status_smart_devices="/dev/ada0"
daily_queuerun_enable="NO"
weekly_output="/var/log/weekly.log"
weekly_status_security_output="/var/log/weeklysecurity.log"
monthly_output="/var/log/monthly.log"
monthly_status_security_output="/var/log/monthlysecurity.log"
# Security audit for base from package base-audit
security_status_baseaudit_enable="YES"
security_status_baseaudit_quiet="NO"
```


----------



## freebuser (Feb 23, 2022)

SirDice said:


> That shouldn't happen. It should only be removed if you have WITHOUT_MAILWRAPPER. But perhaps only /etc/mail/mailer.conf is removed, try just creating it with the information from `pkg info -D ssmtp`.
> 
> 
> 
> ...



What I meant was editing periodic script not mailer.conf   (I hope you meant mailer.conf too)

SirDice, does your system has the 'mail' program, in my system this got deleted with `make delete-old` command

In `periodic` it calls for `mail -s "subject"` unfortunately `-s` is not supported by ssmtp and periodic errors out. Still works but no email.


----------



## freebuser (Feb 23, 2022)

mer said:


> If you don't mind physically looking at log files, periodic can be setup to send output to files instead of emails.
> This is what I put in my /etc/periodic.conf
> 
> ```
> ...



I prefer to have them sent to my email, but thanks for pointing it to me.


----------



## Alain De Vos (Feb 23, 2022)

I have the following in /etc/src.conf :

```
WITH_MAILWRAPPER=yes
WITHOUT_SENDMAIL=yes
```


----------



## SirDice (Feb 23, 2022)

freebuser said:


> @SirDice, does your system has the 'mail' program, in my system this got deleted with `make delete-old` command


Yes, but I don't have a custom src.conf(5). As far as I know /usr/bin/mail isn't part of sendmail, so it shouldn't get removed.


----------



## freebuser (Feb 23, 2022)

SirDice said:


> Yes, but I don't have a custom src.conf(5). As far as I know /usr/bin/mail isn't part of sendmail, so it shouldn't get removed.



Just posting my make.conf for completeness:


```
WITHOUT_NOUVEAU=YES
TARGET_ARCH=amd64
MAKE_JOBS_NUMBER?=6
DEFAULT_VERSIONS+=ssl=openssl
OPENSSLBASE=/usr/local  # Use ports version of openssl with TLS 1.2
OPTIONS_UNSET+=IPV6       # Build ports with IPv6 option
OPTIONS_UNSET+=GNOME    # Build ports w/o Gnome
WITHOUT_GSSAPI=yes      # LibreSSL can't use base's GSSAPI, alternate can be set from make.conf
################################################################################
#       UNSET a few foreign languages
#
OPTIONS_UNSET+=\
        LADSPA LANG_AF LANG_AK LANG_AM LANG_AR LANG_AST LANG_BB \
        LANG_BE LANG_BG LANG_BN LANG_BR LANG_BS LANG_CA LANG_CS \
        LANG_CY LANG_DA LANG_DE LANG_EL LANG_EO LANG_ES LANG_ET \
        LANG_EU LANG_FA LANG_FI LANG_FR LANG_FY LANG_GA LANG_GB \
        LANG_GD LANG_GL LANG_GU LANG_HE LANG_HI LANG_HR LANG_HU \
        LANG_ID LANG_IS LANG_IT LANG_JA LANG_JP LANG_KK LANG_KN \
        LANG_KO LANG_KU LANG_LG LANG_LK LANG_LT LANG_LV LANG_MAI \
        LANG_MK LANG_ML LANG_MN LANG_MR LANG_NB LANG_NL LANG_NN \
        LANG_NSO LANG_OR LANG_PA LANG_PBR LANG_PL LANG_PT LANG_RM \
        LANG_RO LANG_RU LANG_SA LANG_SC LANG_SE LANG_SI LANG_SK \
        LANG_SL LANG_SM LANG_SON LANG_SQ LANG_SR LANG_SV LANG_TA \
        LANG_TE LANG_TH LANG_TR LANG_UA LANG_UK LANG_VI LANG_ZA \
        LANG_ZU LANG_TW


################################################################################
#       Override TESSERACT_LANGS in port Makefile
#
TESSERACT_LANGS=eng
graphics_yagf_SET+=TESSERACT
graphics_yagf_UNSET+=CUNEIFORM
OPTIONS_UNSET+=DOCS NLS EXAMPLES DEBUG ASPELL GNUTLS IDN X11 GUI TESTS
#using opensmtpd from ports
WITHOUT_SENDMAIL=YES
WITHOUT_DMAGENT=YES
#using unbound from ports
WITHOUT_UNBOUND=YES
#using xinetd from ports
WITHOUT_INETD=YES
#using openntpd from ports
WITHOUT_NTP=YES
#BSD grep instead of GNU grep
WITH_BSD_GREP=YES
#using git to sync ports tree
WITHOUT_PORTSNAP=YES
WITHOUT_FREEBSD_UPDATE=YES
#Hyper-V guest tools
WITHOUT_HYPERV=YES

WITHOUT_MODULES=3dfx 3dfx_linux iwlwifi iwlwififw wlan wlan_acl wlan_amrr wlan_ccmp wlan_rssadapt wlan_tkip wlan_wep wlan_xauth
```


----------



## SirDice (Feb 23, 2022)

Some of those things need to be set in src.conf(5), not make.conf(5).


----------

