Hi all, 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 2525action "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 <http://hercules.wherewithal.nl> ESMTP OpenSMTPDsmtp: 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 <http://mail-lf1-f43.google.com>smtp: 0x558ea16527c0: STATE_CONNECTED -> STATE_HELOsmtp: 0x558ea16527c0: >>> 250-hercules.wherewithal.nl <http://250-hercules.wherewithal.nl> Hello mail-lf1-f43.google.com <http://mail-lf1-f43.google.com> [84.86.60.125], pleased to meet yousmtp: 0x558ea16527c0: >>> 250-8BITMIMEsmtp: 0x558ea16527c0: >>> 250-ENHANCEDSTATUSCODESsmtp: 0x558ea16527c0: >>> 250-SIZE 36700160smtp: 0x558ea16527c0: >>> 250-DSNsmtp: 0x558ea16527c0: >>> 250 HELPsmtp: 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] <[email protected]>> SIZE=3081mproc: dispatcher -> queue : 8 IMSG_SMTP_MESSAGE_CREATEimsg: queue <- dispatcher: IMSG_SMTP_MESSAGE_CREATE (len=8)queue-backend: queue_message_create() -> 1 (71fef0c8)mproc: queue -> dispatcher : 16 IMSG_SMTP_MESSAGE_CREATEimsg: dispatcher <- queue: IMSG_SMTP_MESSAGE_CREATE (len=16)smtp: 0x558ea16527c0: >>> 250 2.0.0 Oksmtp: 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] <[email protected]>>mproc: dispatcher -> lka : 295 IMSG_SMTP_EXPAND_RCPTimsg: lka <- dispatcher: IMSG_SMTP_EXPAND_RCPT (len=295)expand: 0x55ad713cfde8: expand_insert() called for address:[email protected] <address%[email protected]>[parent=(nil), rule=(nil)]expand: 0x55ad713cfde8: inserted node 0x55ad713d71a0expand: lka_expand: address: [email protected] <[email protected]> [depth=0]lookup: match "84.86.60.125" as netaddr in table static:<anyhost> -> truelookup: match "wherewithal.nl <http://wherewithal.nl>" as domain in table static:<localnames> -> falseno rule matchedmproc: lka -> dispatcher : 35 IMSG_SMTP_EXPAND_RCPTexpand: 0x55ad713cfde8: clearing expand treeimsg: dispatcher <- lka: IMSG_SMTP_EXPAND_RCPT (len=35)smtp: 0x558ea16527c0: >>> 550 Invalid recipient: <[email protected] <[email protected]>>782cc2bf38e66622 smtp failed-command command="RCPT TO:<[email protected] <[email protected]>>" result="550 Invalid recipient: <[email protected] <[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: <<< QUITsmtp: 0x558ea16527c0: >>> 221 2.0.0 Byesmtp: 0x558ea16527c0: STATE_HELO -> STATE_QUITsmtp: 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
