Score:0

Sendmail does not masquerade the hostname.domain combination

ru flag

My MASQUERADE settings looks as follows...

dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl #
LOCAL_DOMAIN(`localhost.localdomain')dnl
dnl #
dnl # The following example makes mail from this host and any additional
dnl # specified domains appear to be sent from mydomain.com
dnl #
MASQUERADE_AS(`wantedomain.com')dnl
dnl #
dnl # masquerade not just the headers, but the envelope as well
dnl #
FEATURE(masquerade_envelope)dnl
dnl #
dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well
dnl #
FEATURE(masquerade_entire_domain)dnl
dnl #
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(localhost02.ux.com.tus)dnl
MASQUERADE_DOMAIN(localhost02)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl

My hosts file contains...

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.101.129 localhost02.ux.com.tus localhost02
[root@localhost02 mail]# hostname -s
localhost02
[root@localhost02 mail]# hostname -f
localhost02.ux.com.tus
[root@localhost02 mail]#

When I'm trying to send a mail, sendmail keeps try to send this with localhost02.ux.com.tus and does not take into account the MASQUERADING settings (I'm expecting [email protected] as the sender)...

[root@localhost02 mail]# mail [email protected]
Subject: TEST
Hello World.
.
EOT
[root@localhost02 mail]# mailq
        /var/spool/mqueue (1 request)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
20JB4OZi054827*      13 Wed Jan 19 12:04 <[email protected]>
                                         <[email protected]>
        Total requests: 1

Any help would be much appreciated!

20222.01.27 - UPDATE

I have created a short shell script, containing the followings...

#!/bin/sh
[email protected]
[email protected]

/usr/sbin/sendmail -i -v -Am -f$SENDER $RECIPIENT <<END
Subject: TEST
From: $SENDER

Hello World.
END

After executing the shell script, I still get a time out error from the SMTP server...

[root@localhost02 mail]# ./sendmail.sh
[email protected]... Connecting to email-smtp.eu-central-1.amazonaws.com. port 587 via relay...
[email protected]... Deferred: Connection timed out with email-smtp.eu-central-1.amazonaws.com.
[root@localhost02 mail]# mailq
        /var/spool/mqueue (6 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
20R7JX1b017298       13 Thu Jan 27 08:19 [email protected]
                 (Deferred: Connection timed out with email-smtp.eu-central-1.)
                                         [email protected]

However telnet connection to the server via port 587 looks OK...

[root@localhost02 mail]# telnet email-smtp.eu-central-1.amazonaws.com 587
Trying 172.27.1.14...
Connected to email-smtp.eu-central-1.amazonaws.com.
Escape character is '^]'.
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-d-B4HOZL4HF JJQ6jMD4ztoBhcmitWhE
451 4.4.2 Timeout waiting for data from client.
Connection closed by foreign host.
[root@localhost02 mail]#

...and finally the content of the /var/log/maillog file...

Jan 27 08:19:33 localhost02 sendmail[17298]: 20R7JX1b017298: [email protected], size=57, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Jan 27 08:25:33 localhost02 sendmail[17298]: 20R7JX1b017298: [email protected], [email protected] (0/0), delay=00:06:00, xdelay=00:06:00, mailer=relay, pri=30057, relay=email-smtp.eu-central-1.amazonaws.com. [18.158.92.82], dsn=4.0.0, stat=Deferred: Connection timed out with email-smtp.eu-central-1.amazonaws.com.
cn flag
Bob
I haven't used sendmail for a long time, but one of the things I do remember quite well is making all the correct changes in the `sendmail.mc` but omitting the step to convert the sendmail.mc to the `sendmail.cf` configuration file that sendmail actually uses. That may happen automatically when sendmail is restarted, but can also require running `m4 sendmail.mc > sendmail.cf` manually before restarting sendmail.
cn flag
Bob
Also https://serverfault.com/questions/710861 suggests that masquerade changes happen only when mail leaves the server, checking in the queue may not be the best place to check and confirm that your settings are correct.
Mike avatar
ru flag
Dear Bob, many thanks for your input! I believe my sendmail.mc is configured correctly and I have generated the .cf file as well as it's necessary of course. My task is to configure sendmail with AWS SMTP, sending mails out from the server.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.