How to disable sendmail completely

hashime

Active Member

Reaction score: 3
Messages: 122

Hi

I am running FreeBSD 10.1 and put
Code:
sendmail_enable="NONE"
in /etc/rc.conf yet /var/log/maillog is full of entries like this:

Code:
May 22 03:01:26 bla sendmail[4531]: t4K114kj058315: to=postmaster, delay=2+00:00:02, xdelay=00:00:00, mailer=relay, pri=1710580, relay=[127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
May 22 03:01:26 bla sendmail[4531]: t4K114kk058315: to=postmaster, delay=2+00:00:02, xdelay=00:00:00, mailer=relay, pri=1712265, relay=[127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]


Also /var/mail/* is accumulating data.

Could anyone tell me how to disable that completely and possible explain how this is happening, what I am missing?

greetings
 

kpa

Beastie's Twin

Reaction score: 1,828
Messages: 6,318

Yes, I have exact same settings on my system that uses mail/dma as the MTA. The
Code:
sendmail_enable="NONE"
setting is in fact deprecated and shouldn't be used, from rc.sendmail(8):

Code:
...
     sendmail_enable
             (str) If set to “YES”, run the sendmail(8) daemon at system boot
             time.  If set to “NO”, do not run a sendmail(8) daemon to listen
             for incoming network mail.  This does not preclude a sendmail(8)
             daemon listening on the SMTP port of the loopback interface.  The
             “NONE” option is deprecated and should not be used.  It will be
             removed in a future release.
...

To completely prevent any sendmail(8) daemons from starting, you must set
the following variables in /etc/rc.conf:

          sendmail_enable="NO"
          sendmail_submit_enable="NO"
          sendmail_outbound_enable="NO"
          sendmail_msp_queue_enable="NO"
...
 

tobik@

Daemon
Developer

Reaction score: 1,404
Messages: 1,909

Some process is still trying to send mails and there is no mail daemon running so mails get queued. It's probably cron(8). According to the man page adding
Code:
cron_flags="-m ''
to /etc/rc.conf should prevent cron from sending mails, but I have never tried that.
 

kpa

Beastie's Twin

Reaction score: 1,828
Messages: 6,318

Some process is still trying to send mails and there is no mail daemon running so mails get queued. It's probably cron(8). According to the man page adding cron_flags="-m ''" to /etc/rc.conf should prevent cron from sending mails, but I have never tried that.

Yeah, it's not so easy to disable internal mails because you have to disable cron(8) and periodic(8) to do so. Installing a lightweight MTA that does just local mail and possibly smarthost is a better idea than disabling mails alltogether.
 
  • Thanks
Reactions: sdf

usdmatt

Daemon

Reaction score: 571
Messages: 1,498

I didn't realize "NONE" was depreciated

Interesting. I've never really liked these options because it's confusing in that "NO" doesn't actually switch sendmail off. I think it would of been better to have "NO" switch sendmail off completely, just like all other applications, and have the default as something like "LOCAL", which only starts the local daemons.

Having said that, it seems a bit strange to completely drop the NONE option all together. As hinted in this post, you really do always need a local MTA to deliver emails sent from the local system. However some people do prefer to use other mailers, and having to put 4 options in /etc/rc.conf to turn off sendmail seems a bit of a backwards step when "NONE" used to be enough.
 

usdmatt

Daemon

Reaction score: 571
Messages: 1,498

There are various services built in that send emails such as cron/periodic. Some of those emails actually contain useful/important information from time to time. It's also possible that other applications installed may have reasons to send emails. Ideally you want some way to actually handle those emails and get them to their destination.

In a default install Sendmail only really runs in order to handle emails from local applications. It's also possible to remove Sendmail and have those emails handled by something else. If you try and run a FreeBSD machine with no local mail handling at all, then you're either going to have to go round meticulously making sure nothing tries to send any emails, or have emails building up on the system with nowhere to go. In the end, it makes the most sense to just have a local mail agent. Removing it is a lot of hassle, causes problems, and what exactly is the actual benefit?
 
  • Thanks
Reactions: sdf
OP
H

hashime

Active Member

Reaction score: 3
Messages: 122

Thanks for the explanation. Where would those mails pile up? Can't i simply link that directory to /dev/null?
 

usdmatt

Daemon

Reaction score: 571
Messages: 1,498

I'm not actually sure. I did turn Sendmail off completely once years ago but that only lasted until I realised it completely broke all local email delivery, and I put it back to defaults. It's possible they may be in /var/spool/clientmqueue?

If you don't want any of the system mail, you can always edit /etc/mail/aliases and direct root to /dev/null. Not exactly advisable but it means all the system mail will be dropped, however mail delivery still technically "works". I still think trying to remove mail handling completely is a bit of a fools errand though.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,512
Messages: 34,309

So how do I stop my cron from sending mails?
Cron always sends any output from processes as email, so you make sure they don't produce output by redirecting their output to /dev/null or by setting MAILTO to "" in your crontab.

Code:
     -m	mailto
	     Overrides the default recipient for cron mail.  Each crontab(5)
	     without MAILTO explicitly set will	send mail to the mailto	mail-
	     box.  Sending mail	will be	disabled by default if mailto set to a
	     null string, usually specified in a shell as '' or	"".

cron(8)

But I'm guessing you're actually referring to the periodic(8) mails. You can turn that off but I really encourage you to send then to a central mailbox and regularly reading them. They contain a treasure trove of important information about the state of your system.
 

ralphbsz

Son of Beastie

Reaction score: 1,717
Messages: 2,675

So how do I stop my cron from sending mails?
Are you sure you want to do this? Because then you don't know when something is wrong with your system. It's the same question as "how do I turn off the red low oil pressure light in my dashboard"? Not by covering it in black tape or removing the light bulb, but by adding oil to your engine.
 
Top