multiple sendmail with seperate config

Currently my mail server is working well enough. However, I would like to try setting up multiple sendmail processses with their own configurations. So I can have one running on port 25 with spam milters, no relays allowed, and deliver mail to dovecot lmtp. Then have a seperate process with its own config running on port 587 that requires tls+auth before it relays.

Is this something people do regularly and is easy to implement? Or is it one of those things that after I begin I will wish I had never attempted.

Thanks
 
This is my progress thus far. Haven't tested in production yet, but seems to be
working on my laptop. First created a /usr/local/etc/rc.d/sendmail-msa rc script.
The main problem seems to be you can't specify an alternate pidfile for each process. Solved see below.

In /etc/rc.conf I added the following lines:
Code:
sendmail_msa_enable="YES"                                                                       
sendmail_msa_flags="-bd -C/etc/mail/sendmail-msa.cf -L sm-msa"
/etc/mail/freebsd.mc
FEATURE(`no_default_msa')dnl

/etc/mail/sendmail-msa.mc
dnl Enable for both IPv4 and IPv6 (optional)
FEATURE(`no_default_msa')dnl
DAEMON_OPTIONS(`Port=587, Name=MSA, M=Ea')dnl adding the a requires auth
dnl DAEMON_OPTIONS(etc, etc
dnl DAEMON_OPTIONS(etc, etc

Also needed to add a mailer to the msa so email from me to me would be delivered.
FEATURE(local_lmtp)dnl
FEATURE(`local_lmtp',`[IPC]',`FILE /var/run/dovecot/lmtp')dnl
MAILER(local)
MAILER(smtp)

I'm sure I'll have to make some more changes, but that should get the ball rolling.

Suggestions for improvement are appreciated.

Thanks,

edgar

And here is the rc script (mostly stolen from from stock sendmail):
Code:
#!/bin/sh                                                                                       
#                                                                                               
# $FreeBSD: releng/11.1/etc/rc.d/sendmail 298887 2016-05-01 16:43:22Z pfg $                     
#                                                                                               
                                                                                               
# PROVIDE: mail                                                                                 
# REQUIRE: LOGIN FILESYSTEMS                                                                   
#       we make mail start late, so that things like .forward's are not                         
#       processed until the system is fully operational                                         
# KEYWORD: shutdown                                                                             
                                                                                               
# XXX - Get together with sendmail mantainer to figure out how to                               
#       better handle SENDMAIL_ENABLE and 3rd party MTAs.                                       
#                                                                                               
. /etc/rc.subr                                                                                 
                                                                                               
name="sendmail_msa"                                                                             
desc="Electronic mail submission agent"                                                         
rcvar="sendmail_msa_enable"                                                                     
required_files="/etc/mail/sendmail-msa.mc"                                                     
start_precmd="sendmail_msa_precmd"                                                             
M4="/usr/bin/m4"                                                                               
                                                                                               
load_rc_config $name                                                                           
command=${sendmail_program:-/usr/sbin/sendmail}                                                 
pidfile=${sendmail_pidfile:-/var/run/${name}.pid} #Need to find a way to make pidfile           
procname=${sendmail_procname:-/usr/sbin/sendmail}                                               
                                                                                               
sendmail_msa_precmd()                                                                           
{                         
        # Need to make the sendmail-msa.cf                                                     
        if [ ! -f /etc/mail/sendmail-msa.mc ]; then                                             
                echo -n "There is no sendmail-msa.mc"                                           
                exit 1                                                                         
        fi                                                                                     
                                                                                               
        if [ ! -f /etc/mail/sendmail-msa.cf ]; then                                             
                ${M4} -D_CF_DIR_=/usr/share/sendmail/cf/ \                                     
                        /usr/share/sendmail/cf/m4/cf.m4 \                                       
                        /etc/mail/sendmail-msa.mc > /etc/mail/sendmail-msa.cf                   
        fi                                                                                     
                                                                                               
}                                                                                               
                                                                                               
run_rc_command "$1"

Need to work on the script so it just goes ahead and remakes the .cf everytime perhaps. As is it only works the first time.
 
Last edited:
Digging through /usr/src/contrib/sendmail/src/readcf.c I found O_PIDFILE which allows us to specify an alternate pidfile, so I added
Code:
-OPidFile=/var/run/sendmail-msa.pid
to my sendmail_msa_flags in /etc/rc.conf and all is well.
 
Back
Top