(Update) Enviroment is Ubuntu server 24.04 and opensmtpd Version: 7.4.0p1-1build4.
Im using Amazon SES with a few validated domains. I don't want to relay emails that are not from authorized domains. My current smtpd.conf is:
table relay_secrets file:/etc/smtpd/relay_secrets
listen on localhost port 25 mask-src hostname MyDomain.com
listen on socket mask-src
action "relay_ses" relay host smtp+tls://ses@email-smtp.us-east-1.amazonaws.com:587 auth <relay_secrets>
match from mail-from "@MyDomain.com" for any action "relay_ses"
match from any reject
And it works:
- An email from root@Mydomain.com to MyEmail@gmail.com pass
- An email from root@Wrongdomain.com to MyEmail@gmail.com is rejected.
But the error is: Invalid recipient: MyEmail@gmail.com. Not sender error. I guess it is because it is the last rule that is deciding not to send the mail. Is there any way to indicate which domains (in From part) are valid?