Your question
When I try to send an email from stalwart, i keep getting the following non-delivery response
Reporting-MTA: dns;mail.mydomain.com
Arrival-Date: Thu, 8 Oct 2026 11:14:23 +0000
Final-Recipient: rfc822;[email protected]
Action: failed
Status: 5.7.23
Diagnostic-Code: smtp;550 [email protected]: Recipient address rejected: Message rejected due to: SPF fail - not authorized. Please see http://www.openspf.net/Why?s=helo;id=mail.mydomain.com;ip=;r=
Remote-MTA: dns;reception.mail-tester.com
As far as i know, this was working previously i think before 0.16.20 (I wasnt keeping tabs). I have Stalwart hosted on my home server running through a pangolin instance on a VPS. Proxy protocol i think is (or was) configured correctly as I used to be able to send email. I think the problem here is that it is not passing the VPS IP address in the email delivery and is then being rejected because it is expecting the VPS IP not my Home IP.
What needs to be configured here so that the SPF checks work with the VPS ID rather than my home IP?
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on
Proxy Protocol only affects how Stalwart sees the IP of inbound connections (useful for SPF/DMARC checks on mail you receive). It has no effect on outbound delivery: when Stalwart sends mail out to the internet, it opens its own direct TCP connection to the recipient’s MX host using whatever IP its network interface actually has, which in your setup is your home IP, not the VPS IP. That’s why mail-tester sees your home IP as the sending IP and SPF fails (your SPF record presumably authorizes the VPS, not your home connection).
To fix this you have two options:
-
Route outbound mail through the VPS so it actually leaves from the VPS’s IP. This is done with an MtaRoute of type Relay pointing at the VPS (which would need its own MTA listening and relaying onward, or simply NAT/forward port 25 outbound through it), selected via the outbound routing strategy. See Routing.
-
Bind outbound connections to the VPS’s IP, if that IP is actually present as a local address on the Stalwart host (e.g. via a tunnel interface), using the sourceIps setting on MtaConnectionStrategy. See Source IP.
Either way, your SPF record for the domain needs to list whichever IP will actually be doing the outbound SMTP handshake, and that IP needs to match what Stalwart actually uses to connect out, which Proxy Protocol does not influence.
This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.
I am not sure how to implement option 1, but sounds like it needs a mail relay service installed on the VPS, or another Stalwart Instance… And I could not get Option 2 working after trying various combinations of IP addresses (local to the VPS and my home network as well as public IP addresses) result in an error 99 at the TCP connection stage of the Mail Delivery Test in the Stalwart UI.
I feel like i’m missing something here, given that it used to work?
Proxy Protocol only works in one direction. It tells Stalwart the real address of clients coming in through Pangolin, but outbound mail never touches the VPS: Stalwart connects to the recipient’s server straight from your home connection, and mail-tester checks that home IP against the SPF record for mail.mydomain.com (the s=helo in the bounce). Error 99 is “address not available”. A source IP has to exist on one of the server’s own interfaces, so the VPS address can’t work there whatever you try.
To send from the VPS address you need something on the VPS that relays the mail: Postfix or a second Stalwart instance acting as a smarthost, or a relay provider, configured as a relay route (Routing | Stalwart). SPF then only has to list the VPS IP. Adding your home IP to SPF also works, but residential ranges sit on most blocklists and plenty of ISPs block outbound port 25, so I wouldn’t rely on it. As for it working before, I’d check whether your home IP changed or the SPF records were edited at some point.
SPF i think has always been managed by my stalwart instance behind a pangolin instance/tunnel on a VPS, but yes my IP address has changed a couple times with changing providers after moving house. Maybe providers like mail-tester have changed their checks to be harder on the incoming mail as part of their tests. either way, I need to just fix it instead of wondering why it w seemed like it worked last time.
Postfix config is doing my head in a little, but you mention Stalwart can act as a relay - is that relatively straight forward (i.e. easier than postfix)?
Yes, a second Stalwart works fine for this and needs no Postfix knowledge. I’ve written the steps in your other topic: Setting up a second Stalwart instance to be an email relay smarthost
Thanks, ill solve this one for now. I am having trouple on my VPS geetting this installed properly, but thats a me issue. Thanks