Configure default Sendmail on FreeBSD to send ONLY outbound to controlled mail relay

Looking to be able to send emails with attachments from cron job outbound only from system. Have no interest in replacing sendmail with ssmtp or postfix. The system is part of one domain while the email address being submitted to is part of a FQDN domain for email hosted in a remote site. (System name abc123.closedsite.local and email domain is notrealdomain.net) We have a controlled mail relay to which we would send the emails for routing into mail system.

Hope to have a cron job kick off script following automated archiving of BIND DNS logs
Code:
/usr/bin/echo "Nightly tasks status" >x | uuencode status.txt status.txt | cat x - | mailx -s "Task Status for log archive" -r "donotreply@notrealdomain.net" 
"bobsmith@notrealdomain.net"

I know that sendmail is installed by default but I do not know how to get a basic config onto the system to allow cron job to send email to mail relay host. Have done the listed things below in an attempt to get it configured but do not know if I am on right path.

Have done the following:


  1. [cmd=]cp freebsd.mc ${HOST}.mc[/cmd]
    [cmd=]cp freebsd.submit.mc ${HOST}.submit.mc[/cmd]

    Edited ${HOST}.mc and added
    Code:
    MASQUERADE_AS(`notrealdomain.net”)
    FEATURE(`masquerade_envelope’)

    Edited /usr/share/sendmail/cf/domain/generic.m4 and did
    Code:
    dnl # EXPOSED_USER(`root’)

    Then [cmd=]make all install[/cmd] from within /etc/mail/.

    Restart daemon => [cmd=]make restart[/cmd] from /etc/mail

  2. [cmd=]vi freebsd.submit.mc[/cmd]
    - looked for
    Code:
    FEATURE(`msp’, `[127.0.0.1]‘)dnl
    - made it
    Code:
    FEATURE(`msp’, `[10.10.10.25]‘)dnl

    Then [cmd=]make all install[/cmd] from within /etc/mail/

    Restart daemon => [cmd=]make restart[/cmd] from /etc/mail.

  3. Added the following to /etc/rc.conf to ensure that system does not accept inbound emails
    Code:
    # Sendmail Settings
    sendmail_enable="NO"

    Followed by:
    [cmd=]/etc/rc.d/sendmail restart[/cmd]


  4. Edit /etc/mail/sendmail.cf to modify
    Code:
    # "Smart" relay host (may be null)
    DS
    to read
    Code:
    # "Smart" relay host (may be null)
    DSmailrelay.notrealdomain.net

    Then [cmd=]make all install[/cmd] from within /etc/mail/.

    Restart daemon => [cmd=]make restart[/cmd] from /etc/mail.

Am I on right path or have I done too much or too little?
 
Editing the cf and m4 files directly is discouraged. Might be necessary sometimes, but...

What you're doing looks complicated, but seems like it could just be done in hostname.mc with SMART_HOST.

# make
(to generate hostname.mc)

Edit and add masquerading and
Code:
define(`SMART_HOST', `mailrelay.notrealdomain.net')

sendmail_submit_enable defaults to on, so that should be fine. Could still add it to /etc/rc.conf to make it obvious.

Then, in /etc/mail,
# make all install restart

The mail relay has to accept mail from this machine, of course.
 
I unfortunately may have made it more complicated then was necessary. Original desire was to simply have system send emails outbound only. To simplify everything and ensure smooth troubleshooting in future (and to ensure I do not venture too far into the land of "NOOB"), I will reverse all of the modifications I made previously unless you made note of them in your post. Thanks.
 
Some time ago, I made something like that. I need to send periodic mail reports to my mail account via isp smtp server.

I procede like that. (starting with a clean /etc/mail/ directory)

Code:
# cd /etc/mail
# make
# ee fqdn.mc

I added these values

Code:
MASQUERADE_AS(`mydomain.com')
FEATURE(`masquerade_envelope')
define(`SMART_HOST', `smtp.myisp.com')

I added my mail account as root alias.

Code:
# ee aliases

Code:
root: root, me@mydomain.com

Modified /usr/share/sendmail/cf/domain/generic.m4 like this

Code:
dnl EXPOSED_USER(`root’)

Then, run :

Code:
# newaliases
# make
# make install
# make restart

And had something working :)

It is a lot similar to what you tried, but I don't know maybe some typo or what.
 
Back
Top