V
V
Vadim Rybalko2011-12-30 12:40:22
FreeBSD
Vadim Rybalko, 2011-12-30 12:40:22

Sendmail tries to deliver locally without looking at smarthost

Greetings. There is a server (actually jail, but it doesn't matter). It is called, for example, engine.example.com. It runs the back-end of the FreeBSD+NGinx+PHP web server. On it, regular sendmail is raised, the settings of which are default, with the exception of smarthost - our relay is indicated here (local.example.com). If a PHP script generates a letter, it is sent by regular means: first it gets to the local sendmail, which then forwards it to the relay, which then sends it to the addressee. The scheme is quite simple and effective. And it works, except for the following:
If I send an email to any address other than so[email protected], it successfully goes to the smarthost, but if I send to [email protected], sendmail tries to deliver the email locally. Naturally, this mailbox does not exist on this server and a delivery error is recorded in the logs. How to make sure that all emails to all domains are delivered via smarthost? And so that native sendmail does not try to deliver anything locally, except for letters for recipients without a domain part.

Smart comments like “install postfix, exim, etc” please don’t leave: if I don’t find a way out, I’ll install it. I want to get to the bottom of the problem, not run away from it.

Below I will illustrate with logs.

This is an attempt to deliver a letter to [email protected], for some reason sendmail tries to deliver it locally, regardless of the smarthost:

Dec 30 01:49:00 engine sendmail[67504]: pBTLn0Fq067504: from=root, size=91, class=0, nrcpts=1, msgid=<[email protected]>, [email protected]
Dec 30 01:49:00 engine sendmail[67504]: pBTLn0Fq067504: [email protected], ctladdr=root(0/0), delay=00:00:00, xdelay=00:00:00, mailer= relay, pri=30091, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Dec 30 01:49:00 engine sendmail[67504]: pBTLn0Fq067504: pBTLn0Fr067504: DSN: User unknown


This is the same sendmail, correctly sends a letter to another mailbox:
Dec 30 02:05:07 engine sm-mta[71184]: pBTM576C071184: from=<[email protected]>, size=2276, class=-60, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=IPv4, relay=engine.example.com [212.24.0.0] (may be forged)
Dec 30 02:05:07 engine sendmail[71183]: pBTM57Pl071183: to=kent2spb <[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=140055, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pBTM576C071184 Message accepted for delivery)
Dec 30 02:05:07 engine sm-mta[71188]: pBTM576C071184: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=140276 , relay=local.example.com. [10.0.0.99], dsn=2.0.0, stat=Sent (OK id=1RgO5z-0009KC-FJ)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
MrCrock, 2011-12-31
@MrCrock

The sendmail mail server considers a mail domain to be local (that is, it handles mail for that domain) in the following cases if records point to the server:
- An A or MX record in the direct DNS zone (verified by the command host domain.name)
- Hostname of the server
- Records in / etc/hosts
- Entries in the reverse DNS zone (checked by the host ip-address command)
- Entries in /etc/mail/local-hosts-names, /etc/mail/virtusertable and the domain name itself can be defined in the sendmail configs (hostname. mc, sendmail.mc and sendmail.cf created from it - the grep -i domain /etc/mail/* command will find these entries.

R
Riateche, 2011-12-30
@Riateche

Specify something in the local-host-names directive that does not match this domain (for example, localhost, a non-existent domain, or an empty value).

I
Ilya_Drey, 2011-12-30
@Ilya_Drey

Do you have a case for the example.com domain as an MX record not registered on this server?

L
like-person, 2016-07-04
@like-person

Found a solution:
color-rain.ru/blog/prochee/sendmail-yandeks-pochta...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question