Solved "Lazy" question about sendmail

zirias@

Developer
Hi all,

Last time I used sendmail must be like 20 years ago :D So, now learning it is the default MTA in FreeBSD base system, I'd like it to do ONE thing: forward all local mail to my real MTA (at the moment Exim 4 on a Debian box), if possible re-writing the domain-part to JUST the domain, excluding the hostname. I know there are projects like ssmtp for that, but well, sendmail is already there, so why install yet another MTA? Does anyone have hints (like: links to docs/HOWTOs) for me to achieve that?
 
We call that a "smarthost".

# cd /etc/mail
# make
# ee `hostname`.mc (or your choice of editor)
Find the line that says
Code:
define(`SMART_HOST', `example.com')
Change it to point to the mail host and save the file.
# make all install restart

The smarthost should do the domain rewriting, but Sendmail can do it also by adding a few other settings to the configuration file and rebuilding it as shown above:
Code:
MASQUERADE_AS(`example.com')
MASQUERADE_DOMAIN(`example.com')
FEATURE(`masquerade_entire_domain')
FEATURE(`masquerade_envelope')
 
This is a bit of an obvious question, but I'm asking to make sure there isn't something I have overlooked.

I use claws-mail as a client/MTA on my desktop workstation. I'm the only user and there are no other clients on the LAN. I see no purpose or benefit to using a dedicated MTA like sendmail or postfix in this setup.

Am I correct or is there any practical aspect I have overlooked?
 
I see no purpose or benefit to using a dedicated MTA like sendmail or postfix in this setup.

Am I correct or is there any practical aspect I have overlooked?

A lot of software sending mail automatically expects a sendmail binary to do the job. That's the reason I want my Sendmail installation to forward it, so it ultimately ends up in my IMAP mailbox.
 
reason I want my Sendmail installation to forward it, so it ultimately ends up in my IMAP mailbox.
Does that mean your email provider is pop3 based? I'm using Gmail IMAP for example, so in the end it's probably the same solution for me.

A lot of software sending mail automatically expects a sendmail binary to do the job
Applications that are not email clients? Can you give some examples? I'm not using any email related application other than claws, so I'm curious.
 
Does that mean your email provider is pop3 based?
I'm my own ;) and of course not, that's why I wrote IMAP.

Can you give some examples? I'm not using any email related application other than claws, so I'm curious.
Scripts executed by cron for example. Even in the base installation, my box sends mail to root when something is wrong. On my central MTA, I forward mail for root to my real user.
 
Lazy answer to the lazy question: There is no need for sendmail or any other MTA for small LANs unless you really want to get messages by email i.e. to a mobile.

The system won’t break if you do not use sendmail. You can very well configure your system that messages end up in appropriate logfiles. This is also true configuring periodic.conf(5). Just look on embedded boxes running FreeBSD: They might be built
Code:
WITHOUT_SENDMAIL=yes
in /etc/src.conf. In fact every FreeBSD installation could be built without it.

If you have only a handful boxes you might prefer reading logfiles without all the email stuff. But there might be a break even point from where on you might love to use mail for notifications.

If FreeBSD substitutes sendmail like OpenBSD did, I might consider using mail/opensmtpd in the future as part of the FreeBSD base system:
Sendmail removed from OpenBSD
• Mail server admins around the world are rejoicing, because sendmail is finally gone from OpenBSD
• With OpenSMTPD being a part of the base system, sendmail became largely redundant and unneeded
• If you've ever compared a "sendmail.cf" file to an "smtpd.conf" file... the different is as clear as night and day
 
Ah, makes sense now. Providing your own email server is an entirely different setup.
Not necessarily. In the default configuration, sendmail does local delivery, so all these system messages end up in /var/mail/root. You might want to forward these even to a mailbox on an external system...

The system won’t break if you do not use sendmail. You can very well configure your system that messages end up in appropriate logfiles.
Well, any tool expecting a working sendmail binary for sending mails will stop sending mails without an MTA installed ... of course this is not "breaking the system". I wasn't aware you can have the base system without sendmail, so I might give it a try -- after all, it's a notebook, so problems won't go unnoticed anyways.
 
Not necessarily. In the default configuration, sendmail does local delivery, so all these system messages end up in /var/mail/root. You might want to forward these even to a mailbox on an external system...


Well, any tool expecting a working sendmail binary for sending mails will stop sending mails without an MTA installed ... of course this is not "breaking the system". I wasn't aware you can have the base system without sendmail, so I might give it a try -- after all, it's a notebook, so problems won't go unnoticed anyways.

The /usr/sbin/sendmail file is not an executable but a symbolic link to mailwrapper(8) (which "owns" the /usr/sbin/sendmail link, it's not owned by Sendmail) that can be configured using the /etc/mail/mailer.conf configuration file to call the appropriate binary for the desired functionality in case the base system Sendmail is not used. This is what I have in my system that is using mail/dma as the local mailer:

Code:
sendmail        /usr/local/libexec/dma
send-mail       /usr/local/libexec/dma
mailq           /usr/local/libexec/dma
 
Find the line that says
Code:
define(`SMART_HOST', `example.com')
Change it to point to the mail host and save the file.

Just for the sake of completeness, it does exactly what I initially wanted using the following defines:
Code:
define(`SMART_HOST', `mail.<my-domain>')
define(`MAIL_HUB', `mail.<my-domain>')
I now intentionally left out the masquerading bits, so it's directly obvious which mails are automatically sent from my FreeBSD box. Thanks again.
 
Back
Top