2

I'm running FreeBSD 11.0-RELEASE.

On default cron is using /usr/lib/sendmail to send user emails. How can I tell/set cron to use /bin/mail instead?

FreeBSD is using the cron version from Paul Vixie, so the -m option sets the email receiver not what mailer to use.

I downloaded the FreeBSD source code and tried the command # make config in /usr/src/usr.sbin/cron/, that ofc does not work since config is not defined. But I think that's an bad idea anyway cause future updates could easy overwrite this?

Thanks for your help!

2

cron by default uses the value of the systemwide _PATH_SENDMAIL macro as the expansion of MAILCMD, the command to use to send messages generated by jobs. In order to use a different mail program, you need to modify the Makefile to define appropriate values for the MAILCMD and MAILARGS macros. The Makefile in the source tree includes commented definitions illustrating possible values, but there appears to be a slight bug in the MAILARGS macro that applies when MAILCMD is defined to be /bin/mail - it has two string expansions, but only receives one string when called, so in the patch in the gist, I removed the first of the expansions.

If you have the patch utility installed (it's in ports, if not), apply this patch (relative to /usr/src/usr.sbin/cron) and build/install cron:

% cd /usr/src/usr.sbin/cron
% make 
% make install

Restart cron, and you should now be using /bin/mail. N.B. this patched version builds cleanly on my system (11-STABLE), but I have not tried using it in place of the default version. Remember that you'll probably need to do this again when you upgrade, since the FreeBSD default is to use /usr/lib/sendmail.

2

The actual path used by cron is /usr/sbin/sendmail which is defined in /usr/include/paths.h. This is usually a symbolic link to mailwrapper(8).

You can change the default behaviour for all applications by modifying /etc/mail/mailer.conf. See mailer.conf(5) for more.

Of course, your /bin/mail would need to have similar semantics to sendmail and you would have to be comfortable with changing the default behaviour for sendmail on the entire system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.