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.