From: stephenf4 on
When relaying outbound messages via a custom mailer, I'm getting
expected DSN bounce messages sent back to root instead of the sender
of the message in my domain. I'd like to get the DSN messages back to
the sender so they know the message didn't make it. Part of the
problem appears that sendmail is trying to use a custom mailer use for
the outbound message during delivery of the DSN bounce message back to
the sender, instead of the esmtp mailer. The custome mailer (named
"relay_port_465") was created to send mails to port 465 instead of
port 25. The outbound messags are going to a localhost TCP socket on
465, which is an SSL tunnel to one my ISP's SMTP server.

The "Service Unavailable" failure on the outbound AUTH relay is
expected. The non-delivery of the DSN message to the original sender
is not expected, and hence the problem I'm seeking help to fix.

I'm running sendmail 8.13.8-2 on CentOS v5. Here's the maillog except
of the problem:

Feb 27 17:32:54 mx sendmail[21597]: o1RMVsUh021594: SMTP outgoing
connect on localhost
Feb 27 17:32:57 mx sendmail[21597]: AUTH=client,
relay=localhost.fleece.name., mech=, bits=0
Feb 27 17:32:57 mx sendmail[21597]: o1RMVsUh021594:
to=<intendedrecipent(a)hotmail.com>, delay=00:01:03, xdelay=00:01:03,
mailer=relay_port_465, pri=122105, relay=localhost.mydomain.net.
[127.0.0.1], dsn=5.0.0, stat=Service unavailable
Feb 27 17:32:57 mx sendmail[21597]: o1RMVsUh021594: o1RMWvUh021597:
DSN: Service unavailable
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUh021597:
to=<sender(a)ispdomain.com>, delay=00:00:00, xdelay=00:00:00,
mailer=relay_port_465, pri=33318, relay=localhost.mydomain.net.,
dsn=5.0.0, stat=Service unavailable
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUh021597: alias MAILER-
DAEMON => postmaster
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUh021597: alias postmaster
=> root
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUh021597: alias postmaster
=> root
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUh021597: o1RMWvUi021597:
return to sender: Service unavailable
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUi021597: to=root,
delay=00:00:00, xdelay=00:00:00, mailer=local, pri=34342, dsn=2.0.0,
stat=Sent
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUi021597: done;
delay=00:00:00, ntries=1
Feb 27 17:32:57 mx sendmail[21597]: o1RMWvUh021597: done;
delay=00:00:00, ntries=1
Feb 27 17:32:57 mx sendmail[21597]: o1RMVsUh021594: done;
delay=00:01:03, ntries=1

For context, I have 3 mail-related hosts in my domain plus my ISP's
relay server, for a total of 4 hosts to consider.
1) mx.mydomain.net - my inbound/outbound sendmail relay server,
fetchmail client to pop3.ispdomain.com, and stunnel server to port 465
smtp.ispdomain.com (and source of maillog and problem)
2) mx2.mydomain.net - my alternative outbound relay server
3) mail.mydomain.net - my mail server which hosts user accounts
4) smtp.ispdomain.com - my ISP's outbound relay server

So, outbound mail starts at my mail host, relays to mx, and then
either relays out to mx2 or smtp.ispdomain.com depending upon the
sender address. user1(a)ispdomain.com sends via smtp.ispdomain.com and
user2(a)mydomain.net sends via mx2.mydomain.net.

I use a sendmail add-on from sourceforge's open-sendmail project
called smarttable to accomplish the sender-based routing/relaying...
http://anfi.homeunix.org/sendmail/smarttab.html

I run an stunnel service on localhost port 465 which provides a tunnel
to smtp.ispdomain.com. I can test this successfully using telnet on
localhost (mx.mydomain.net).

Here's my mailertable, smarttable, and sendmail.mc files...

/etc/mail/mailertable

mydomain.net SMTP:[mail.mydomain.net]
user1(a)ispdomain.com SMTP:[mail.mydomain.net]

---
/etc/mail/smarttable:

@mydomain.net ESMTP:[mx2.mydomain.net]
# relay mailer sends to alternate port (e.g., port 465 for stunnel to
smtp.ispdomain.com)
@bellsouth.net relay_port_465:[localhost]
# relay for <> sender [version 8.2+ of smarttable]
@ SMTP:[mail.mydomain.net]
---
/etc/mail/sendmail.mc:
divert(-1)dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`')dnl
OSTYPE(`linux')dnl
define(`confDOMAIN_NAME', `mx.mydomain.net')dnl
define(`confSMTP_LOGIN_MSG', `$j sendmail; $b')dnl
define(`confLOG_LEVEL', `15')dnl
define(`confMILTER_LOG_LEVEL', `9')dnl
define(`confDEF_USER_ID', ``8:12'')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST', `True')dnl
define(`confDONT_PROBE_INTERFACES', `True')dnl
define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/var/log/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS',
`authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
define(`confTO_QUEUERETURN', `14d')dnl
define(`confTO_IDENT', `0')dnl
FEATURE(`dnsbl', `zen.spamhaus.org', `571 mail from $&{client_addr}
refused by destination system policy - see Spamhaus ZEN blocklist at
http://www.spamhaus.org')dnl
FEATURE(`authinfo')dnl
FEATURE(`no_default_msa', `dnl')dnl
FEATURE(`smrsh', `/usr/sbin/smrsh')dnl
FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl
FEATURE(`smarttable', `hash -o /etc/mail/smarttable.db')dnl
MAILER_DEFINITIONS
Mrelay_port_465, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP,
R=EnvToSMTP, E=\r\n, L=990, T=DNS/RFC822/SMTP, A=TCP $h 465
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
define(`confMAX_DAEMON_CHILDREN', `20')dnl
define(`confCONNECTION_RATE_THROTTLE', `2')dnl
define(`confBAD_RCPT_THROTTLE',`1')dnl
FEATURE(local_procmail, `', `procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
INPUT_MAIL_FILTER(`mimedefang', `S=unix:/var/spool/MIMEDefang/
mimedefang.sock, F=T, T=S:1m;R:1m')
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
FEATURE(`accept_unresolvable_domains')dnl
LOCAL_DOMAIN(`mx.mydomain.net')dnl
LOCAL_DOMAIN(`localhost')dnl
VIRTUSER_DOMAIN(`mydomain.net')
VIRTUSER_DOMAIN(`ispdomain.com')
MAILER(smtp)dnl
MAILER(procmail)dnl
From: stephenf4 on
correction to original post in thread... the smarttable I included
should read:

@mydomain.net ESMTP:[mx2.mydomain.net]
# relay mailer sends to alternate port (e.g., port 465 for stunnel to
smtp.ispdomain.com)
@ispdomain.com relay_port_465:[localhost]
# relay for <> sender [version 8.2+ of smarttable]
@ SMTP:[mail.mydomain.net]

I gave my ISP's anonymity away. whoops. :-)