First, some baseline data:
r...@server:~# cat /etc/mailer.conf | grep -v '^#'
sendmail /usr/sbin/smtpd
send-mail /usr/sbin/smtpctl
mailq /usr/sbin/smtpctl
makemap /usr/libexec/smtpd/makemap
newaliases /usr/libexec/smtpd/makemap
Not sure if this is right or not, it doesn't seem to be documented
anywhere yet.
r...@server:~# cat /etc/mail/smtpd.conf | egrep -v '^#|^$'
ExtIF = "fxp0"
IntIF = "em0"
listen on lo0
listen on $ExtIF
listen on $IntIF
map "aliases" { source db "/etc/mail/aliases.db" }
accept from all for domain "athompso.net" deliver to mbox
accept from 127.0.0.1 for local deliver to mbox
accept from 192.168.206.0/24 for local deliver to mbox
accept from 192.168.206.0/24 for all relay via
shawmail.wp.shawcable.net
Note, last line may be wrapped in this post, not in the file.
I've run newalises (exec'ing /usr/libexec/smtpd/makemap, via mailwrapper
as appropriate).
Now, when I try to mail myself something local:
r...@server:~# smtpd -v
warning: could not load cert: lo0, no SSL/TLS/AUTH support
warning: could not load cert: fxp0, no SSL/TLS/AUTH support
warning: could not load cert: em0, no SSL/TLS/AUTH support
r...@server:~# tail -1 /var/log/maillog
Dec 17 02:30:35 server smtpd[8165]: startup
so far so good...
r...@server:~# mail root
Subject: test
test
.
EOT
r...@server:~# send-mail: rcpt to [email protected] refused by
server
r...@server:~# mail athompso
Subject: test
test
.
EOT
r...@server:~# send-mail: rcpt to [email protected] refused
by server
r...@server:~# mail [email protected]
Subject: test
test
.
EOT
r...@server:~# send-mail: rcpt to [email protected] refused by
server
r...@server:~# mail athom...@localhost
Subject: test
test
.
EOT
r...@server:~# send-mail: rcpt to athom...@localhost refused by server
Note, I've tried bare username, @localhost and @fqdn, none of which
worked.
r...@server:~# tail -1 /var/log/maillog
Dec 17 02:30:35 server smtpd[8165]: startup
hmm... nothing!
OK, kill smtpd, restart with debug:
r...@server:~# pkill smtpd
r...@server:~# tail -10 /var/log/maillog
Dec 17 02:30:35 server smtpd[8165]: startup
Dec 17 02:34:42 server smtpd[6812]: smtp server exiting
Dec 17 02:34:42 server smtpd[13481]: mail transfer agent exiting
Dec 17 02:34:42 server smtpd[18921]: queue handler
Dec 17 02:34:42 server smtpd[8577]: runner handler
Dec 17 02:34:42 server smtpd[256]: mail filter exiting
Dec 17 02:34:42 server smtpd[75]: mail delivery agent exiting
Dec 17 02:34:42 server smtpd[10741]: lookup agent exiting
Dec 17 02:34:42 server smtpd[22494]: control process exiting
Dec 17 02:34:42 server smtpd[8165]: parent terminating
r...@server:~# smtpd -d -v
warning: could not load cert: lo0, no SSL/TLS/AUTH support
warning: could not load cert: fxp0, no SSL/TLS/AUTH support
warning: could not load cert: em0, no SSL/TLS/AUTH support
startup [debug mode]
smtpd: max open files 1024
smtpd: will accept at most 768 clients
parent_send_config: configuring smtp
parent_send_config_client_certs: configuring smtp
parent_send_config_ruleset: reloading rules and maps
parent_send_config_ruleset: reloading rules and maps
smtp_setup_events: listen on IPv6:fe80:1::211:aff:fe57:6836 port 25
flags 0x0 cert "em0"
smtp_setup_events: listen on 192.168.206.1 port 25 flags 0x0 cert
"em0"
smtp_setup_events: listen on 174.5.101.109 port 25 flags 0x0 cert
"fxp0"
smtp_setup_events: listen on IPv6:fe80:3::230:48ff:fe23:22a3 port 25
flags 0x0 cert "fxp0"
smtp_setup_events: listen on IPv6:fe80:5::1 port 25 flags 0x0 cert
"lo0"
smtp_setup_events: listen on IPv6:::1 port 25 flags 0x0 cert "lo0"
smtp_setup_events: listen on 127.0.0.1 port 25 flags 0x0 cert "lo0"
Finished initialization here.
Ran "mail root" on another console, with identical results as before,
but here's the debug output:
session_pickup: greeting client
command: EHLO args: server.athompso.net
command: MAIL FROM args: <[email protected]>
session_rfc5321_mail_handler: sending notification to mfa
matching: server.athompso.net to athompso.net
matching: server.athompso.net to localhost
matching: server.athompso.net to server.athompso.net
matching: server.athompso.net to athompso.net
matching: server.athompso.net to localhost
matching: server.athompso.net to server.athompso.net
smtp_dispatch_mfa: mfa handled return path
queue_dispatch_smtp: creating message file
smtp_dispatch_queue: queue handled message creation
command: RCPT TO args: <[email protected]>
matching: server.athompso.net to athompso.net
smtp_dispatch_mfa: mfa handled return path
session_destroy: killing client: 0x7cafa000
So... I have no idea what all that output means, but I do note that
there's not a single thing in it I would call an error message.
OTOH, if I do this:
r...@server:~# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 server.athompso.net ESMTP OpenSMTPD
HELO localhost
250 server.athompso.net Hello localhost [127.0.0.1], pleased to meet
you
MAIL FROM: <[email protected]>
250 Sender ok
RCPT TO: <[email protected]>
250 Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Subject: test
test
.
250 1261039078.QgdVXLYA6OPtApgp Message accepted for delivery
QUIT
221 server.athompso.net Closing connection
Connection closed by foreign host.
r...@server:~#
then I get additional debug output which *does* look different:
smtp_accept: incoming client on listener: 0x87d98800
smtp_accept: accepted client on listener: 0x87d98800
lookup_ptr 127.0.0.1
lookup_ptr success
session_pickup: greeting client
command: HELO args: localhost
command: MAIL FROM args: <[email protected]>
session_rfc5321_mail_handler: sending notification to mfa
matching: server.athompso.net to athompso.net
matching: server.athompso.net to localhost
matching: server.athompso.net to server.athompso.net
matching: server.athompso.net to athompso.net
matching: server.athompso.net to localhost
matching: server.athompso.net to server.athompso.net
smtp_dispatch_mfa: mfa handled return path
queue_dispatch_smtp: creating message file
smtp_dispatch_queue: queue handled message creation
command: RCPT TO args: <[email protected]>
matching: server.athompso.net to athompso.net
matching: server.athompso.net to localhost
matching: server.athompso.net to server.athompso.net
USERNAME: root
matching: server.athompso.net to athompso.net
matching: server.athompso.net to localhost
matching: server.athompso.net to server.athompso.net
smtp_dispatch_queue: queue acknowledged message submission
command: DATA args: (null)
smtp_dispatch_queue: queue handled message creation
smtp_dispatch_queue: queue acknowledged message submission
1261039078.QgdVXLYA6OPtApgp: from=<[email protected]>, size=
217, nrcpts=1, proto=SMTP, relay=localhost [127.0.0
.1]
executing mail.local
1261039078.QgdVXLYA6OPtApgp.4109318861: to=<[email protected]>,
delay=6, stat=Sent
external mda exited okay
command: QUIT args: (null)
session_destroy: killing client: 0x80ae4000
So... altering /etc/mailer.conf to read:
send-mail /root/test.sh
where /root/test.sh consists merely of:
#!/bin/sh
set +x
echo "Invoked as: $0 $@"
while read X; do echo $X; done
I get this output:
r...@server:~# mail root
Subject: test
test
.
EOT
r...@server:~# Invoked as: /root/test.sh -i -- root
To: root
Subject: test
test
r...@server:~#
Which looks pretty much exactly like I expected. (Obviously, there's no
additional debug output from smtpd -d -v, since we didn't *do* anything
except echo back some data.
So. WTF am I doing wrong? Help!
-Adam Thompson
[email protected]