Solved Definitive steps for configuring sendmail as 'nullclient'

I have a number of jails, and their host, running sendmail with its default configuration. I want to configure sendmail to send all mail, even mail destined for local users (even root), to an external MTA via SMTP. I've seen some material on the internet about this, and one suggestion was adding to /etc/mail/freebsd.mc:

Code:
FEATURE(nullclient, `<hostname of mail server>')dnl

However, this does not seem to work, since in /var/log/maillog I can see sendmail handling mail and rejecting mail for unknown users, for example.

I know very little about sendmail and relatively little about mail in general, but it seems like there is a simple solution out there given how straightforward the problem is.
Thanks
 
Use the external MTA as a so-called "smart host". That will cause sendmail to send all its mail to this "smart host" and assumes that host will take care of the rest.

This is the basic gist of it:
Code:
cd /etc/mail
make
vi $(hostname -f).submit.mc
# Add define(`SMART_HOST', `my.upstream.mail.host') to the mc file.
make install
make restart
It might not be entirely correct, I'm typing this from the top of my head. But it should provide you with enough clues to figure it out.
 
  • Thanks
Reactions: pkc
Actually, this works a little different; the smart host definition is already included by default (but commented out) in the other file:
Code:
peter@zefiris:/etc/mail $ grep -i smart `hostname -f`.mc
define(`SMART_HOST', `smtp.intranet.lan')
So just edit this file, remove the dnl and change the hostname into the right name.

However, this won't have a result for mail sent to local users, such as root. You can achieve that by editing /etc/mail/aliases:
Code:
peter@zefiris:/etc/mail $ grep root aliases | head -5
# Pretty much everything else in this file points to "root", so
# you would do well in either reading root's mailbox or forwarding
# root's email from here.
root:   peter
postmaster: root
In this case all e-mail is sent to my local account on the server, but I could just as easily have changed this into a remote e-mail address, then everything would be forwarded.
 
  • Thanks
Reactions: pkc
Thanks both, it is working now, not sure what I did exactly since I did one thing a while ago and then just now did another thing.
Wanted to mention in case someone else is having an issue that if this other host is referred to by IP address and there is no MX record one will want to use the [ ] notation like, [192.168.1.1]
 
Weird. It works for me... there's even an example for root in /etc/mail/aliases:

Code:
# Pretty much everything else in this file points to "root", so
# you would do well in either reading roots mailbox or forwarding
# roots email from here.

# root: me@my.domain

You could try a .forward in root's home directory.
 
I tried to set alias like root: mailbox@myisp.com then run newaliases and service sendmail restart but emails aren't sent.
Look in /var/log/maillog to see why it's stuck. Or maybe it does get sent but your destination silently drops it as spam. There could be a million and one reasons why it's not working, check your logs.
 
/etc/rc.conf
hostname = "mydomain.com"

/etc/mail/aliases
root: user@otherdomain.com
Cron messages lead to an error message

Mail Delivery Subsystem Returned mail: see transcript for details
MAILER-DAEMON@mydomain.com

The original message was received at Tue, 17 Dec 2019 03:44:31 +0200 (EET) from localhost [127.0.0.1]

----- The following addresses had permanent fatal errors ----- user@otherdomain.com
(reason: 550-Verification failed for <root@mydomain>)
(expanded from: <root@mydomain>)

----- Transcript of session follows ----- ... while talking to mail.otherdomain.com.:
>>> DATA
<<< 550-Verification failed for <root@mydomain> <<< 550-No Such User Here <<< 550 Sender verify failed 550 5.1.1 user@otherdomain.com... User unknown <<< 503-All RCPT commands were rejected with this error:
<<< 503-Sender verify failed
<<< 503 Valid RCPT command must precede DATA
 
There are two failures, the first is that the recipient doesn't like your source address. The second is that the destination email address doesn't exist.
 
Back
Top