Hi all,

(Note: I used some italics text in my previous message leading to
formatting problems. Here's the same message without any text formatting.)

I am trying to set up mail for a few domains, mostly as a hobby project.
After having considered Exim and Postfix and being intimidated by their
complexity, I am now trying to give opensmtpd a try, if only because the
smtpd.conf man page is refreshingly short.

This is also a learning experience for me, so I want to understand what the
smtp daemon is doing. In the process, I'm getting stuck quite early, so I
hope somebody on the list will be able to help.

Let me describe where I am now.

First thing to note is that my current ISP closed off port 25 (both inbound
and outbound), meaning that my test server (hercules.wherewithal.nl) cannot
directly serve as an MX for my test domain (wherewithal.nl).

To get around that, I installed a Raspberry Pi in another location (a
different ISP that doesn't block port 25 traffic). That raspberry
implements a TCP-level relay from its port 25 to port 2525 of my test
server, using the "rinetd" relay software. The MX record of my test domain
points to the Raspberry Pi. So whenever a connection is made to port 25 of
the MX of my domain, this results in an incoming TCP connection on port
2525 on my test server. I have confirmed that this works.

My test server is a Debian 13 machine that has opensmtpd version 7.6.0
installed.

I have a very minimal /etc/smtpd.conf for test purposes. Apart from
comments, it contains just these three lines:

listen on 0.0.0.0 port 2525
action "my-test-mda" mda "/home/sidney/mda/mda.py exitcode=0"
match from any action "my-test-mda"

The "mda.py" script logs info (arguments, environment, stdin) to a file.
The idea here is for me to be able to see what happens, and to learn how
opensmtpd works.

This particular action works, at least for locally generated messages.
Crontab messages, for example, are "delivered" to my mda.py script and
logged. So far, so good.

The next step for me is to understand delivery from the outside world. To
this end, I am running smtpd like this:

/usr/sbin/smtpd -d -T all

Now when I send an mail to my test domain using Google mail, I do see an
incoming SMTP connection and a delivery attempt. Here's the relevant part.

Note: "hercules.wherewithal.nl" is my test server. 84.86.60.125 is the
raspberry pi that is the acting MX for the wherewithal domain.

smtp: 0x558ea16527c0: >>> 220 hercules.wherewithal.nl ESMTP OpenSMTPD
smtp: 0x558ea16527c0: IO_LOWAT <io:0x558ea1656480 fd=12 to=300000 fl=W ib=0
ob=0>
smtp: 0x558ea16527c0: IO_DATAIN <io:0x558ea1656480 fd=12 to=300000 fl=R
ib=30 ob=0>
smtp: 0x558ea16527c0: <<< EHLO mail-lf1-f43.google.com
smtp: 0x558ea16527c0: STATE_CONNECTED -> STATE_HELO
smtp: 0x558ea16527c0: >>> 250-hercules.wherewithal.nl Hello
mail-lf1-f43.google.com [84.86.60.125], pleased to meet you
smtp: 0x558ea16527c0: >>> 250-8BITMIME
smtp: 0x558ea16527c0: >>> 250-ENHANCEDSTATUSCODES
smtp: 0x558ea16527c0: >>> 250-SIZE 36700160
smtp: 0x558ea16527c0: >>> 250-DSN
smtp: 0x558ea16527c0: >>> 250 HELP
smtp: 0x558ea16527c0: IO_LOWAT <io:0x558ea1656480 fd=12 to=300000 fl=W ib=0
ob=0>
smtp: 0x558ea16527c0: IO_DATAIN <io:0x558ea1656480 fd=12 to=300000 fl=R
ib=46 ob=0>
smtp: 0x558ea16527c0: <<< MAIL FROM:<[email protected]> SIZE=3081
mproc: dispatcher -> queue : 8 IMSG_SMTP_MESSAGE_CREATE
imsg: queue <- dispatcher: IMSG_SMTP_MESSAGE_CREATE (len=8)
queue-backend: queue_message_create() -> 1 (71fef0c8)
mproc: queue -> dispatcher : 16 IMSG_SMTP_MESSAGE_CREATE
imsg: dispatcher <- queue: IMSG_SMTP_MESSAGE_CREATE (len=16)
smtp: 0x558ea16527c0: >>> 250 2.0.0 Ok
smtp: 0x558ea16527c0: IO_LOWAT <io:0x558ea1656480 fd=12 to=300000 fl=W ib=0
ob=0>
smtp: 0x558ea16527c0: IO_DATAIN <io:0x558ea1656480 fd=12 to=300000 fl=R
ib=32 ob=0>
smtp: 0x558ea16527c0: <<< RCPT TO:<[email protected]>
mproc: dispatcher -> lka : 295 IMSG_SMTP_EXPAND_RCPT
imsg: lka <- dispatcher: IMSG_SMTP_EXPAND_RCPT (len=295)
expand: 0x55ad713cfde8: expand_insert() called for
address:[email protected][parent=(nil), rule=(nil)]
expand: 0x55ad713cfde8: inserted node 0x55ad713d71a0
expand: lka_expand: address: [email protected] [depth=0]
lookup: match "84.86.60.125" as netaddr in table static:<anyhost> -> true
lookup: match "wherewithal.nl" as domain in table static:<localnames> ->
false
no rule matched
mproc: lka -> dispatcher : 35 IMSG_SMTP_EXPAND_RCPT
expand: 0x55ad713cfde8: clearing expand tree
imsg: dispatcher <- lka: IMSG_SMTP_EXPAND_RCPT (len=35)
smtp: 0x558ea16527c0: >>> 550 Invalid recipient: <[email protected]>
782cc2bf38e66622 smtp failed-command command="RCPT TO:<[email protected]>"
result="550 Invalid recipient: <[email protected]>"
smtp: 0x558ea16527c0: IO_LOWAT <io:0x558ea1656480 fd=12 to=300000 fl=W ib=0
ob=0>
smtp: 0x558ea16527c0: IO_DATAIN <io:0x558ea1656480 fd=12 to=300000 fl=R
ib=6 ob=0>
smtp: 0x558ea16527c0: <<< QUIT
smtp: 0x558ea16527c0: >>> 221 2.0.0 Bye
smtp: 0x558ea16527c0: STATE_HELO -> STATE_QUIT
smtp: 0x558ea16527c0: IO_LOWAT <io:0x558ea1656480 fd=12 to=300000 fl=W ib=0
ob=0>

What happens, apparently, is that the message dropoff is rejected with a
"550 Invalid recipient" response. This is unexpected for me at least,
because of my "match from any" action. The message appears to be rejected
and doesn't make it to the queue.

Now I have read the "smtpd.conf" man page a few times, but I don't see an
explanation about why the message is rejected.

My questions:

* Is this behavior expected, and if so, is it documented?
* What should I change in my smtpd.conf to get incoming messages accepted
into the mail queue?

As soon as that works, I can direct my attention to the following steps --
altering the deliver-to of the messages, and relaying them to my ISPs SMTP
server. I probably will have some questions about that too. But first I
need to make sure messages are queued.

Any help will be appreciated, cheers,

 Sidney

Reply via email to