Mail relay for a single domain

Guys,

In 2023, what's the easiest way how to forward mail traffic from a super tiny FreeBSD server for a single domain to a different domain/server.
I mean: I'd like all the emails going to @my-freebsd-server.com to be forwarded to @should-go-here.com. Nothing else.

All tutorials I've found so far for sendmail, ssmtp etc. were so long that I think there should be a better way how to achieve this.

Thank you! (Using 13.2)
 
Why would you need any forwarding? If this "should-go-here" server knows it should accept mail for your domain, all it takes is correct DNS configuration, IOW have MX for your domain point to "should-go-here".
 
copy /etc/mail/freebsd.mc to /etc/mail/mytest.mc
add this to mytest.mc after the virtusertable feature
Code:
FEATURE(`stickyhost')
define(`MAIL_HUB', `esmtp:should-go-here.com.')dnl
define(`LOCAL_RELAY', `esmtp:should-go-here.com')dnl

in /etc/mail/virtusertable (create it)
@my-freebsd-server.com %1@should-go-here.com
in /etc/mail
make maps
make mytest.cf
cp mytest.cf sendmail.cf
make restart
enjoy
 
all the emails going to @my-freebsd-server.com
This sounds to me as it's about incoming mail.

But indeed, the question makes much more sense when talking about outgoing mail, so maybe the above was just something like a typo?

In that case, instead of sendmail, I'd prefer dma(8) (also in base) for its simplicity. All you have to do is configure the SMARTHOST variable in /etc/dma/dma.conf. You might want to also set NULLCLIENT depending on your needs, it even disables any local delivery.

To use dma instead of sendmail, set this in /etc/mail/mailer.conf:
Code:
sendmail        /usr/libexec/dma
mailq           /usr/libexec/dma
newaliases      /usr/libexec/dma
and prevent any sendmail daemon from running by adding this to /etc/rc.conf:
Code:
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
 
Why would you need any forwarding? If this "should-go-here" server knows it should accept mail for your domain, all it takes is correct DNS configuration, IOW have MX for your domain point to "should-go-here".
Unfortunately, cannot change any of the MX records. This is given.
 
Back
Top