How to determine if a SMTP transaction is inbound or outbound?

Erik Aigner asked:

I was wondering how to distinguish inbound from outbound SMTP transactions.

Normally this would be a straightforward question, however my SMTP server has to handle a special case:

  • Other domains might point to my MX domain (mail address aliases)

What outbound criteria should I check for?
Is it as simple as checking if the transaction is authenticated (via the AUTH command), or do any other rules apply (derived from the FROM/RCPT addresses)?
I guess alias addresses can be detected by resolving their MX?

My answer:

If the sender is in your domain, it’s outbound.

If the recipient is in your domain, it’s inbound.

If neither are in your domain, it’s relay, and drop it like a hot potato.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.