Why does Postfix accept MAIL FROM from an email it’s not responsible for

emailemail-serverpostfix

I'm testing a postfix installation. I noticed that if I try to send mail from a fictitious account on another domain that isn't mine (unknown@NotMyDomain.com), to one of my local users (user@MyDomain.com), the email still gets delivered to my user.

MAIL FROM:<unknown@notmydomain.com>

RCPT TO:<user@mydomain.com>

I'm not sure if this is normal behaviour or if it can cause problems. For example, I'm worried that users could use the server to send spoofed emails that aren't really originating from the email accounts they claim to be originating from.

P.S. I'm still in the early stages of learning postfix, so not sure if my question makes sense.


As per @DerfK's comment, I tested for an open relay (where both MAIL FROM and RCPT TO aren't hosted on this server), and this is what I get. For some reason it accepts the RCPT TO, then says goodbye AFTER I type the subject. So is this good or bad?

HELO test.mydomain.com
250 mail
MAIL FROM:<user@notmydomain1.com>
250 2.1.0 Ok
RCPT TO:<user@notmydomain2.com>
250 2.1.5 Ok
Subject: testing for open relay
221 2.7.0 Error: I can break rules, too. Goodbye.
Connection closed by foreign host.

Best Answer

You forgot Data! I had exactly this problem. You have to have command data, then subject. So it resolves your problems. Look like this:

HELO test.mydomain.com

250 mail

MAIL FROM:<user@notmydomain1.com>

250 2.1.0 Ok

RCPT TO:<user@notmydomain2.com>

250 2.1.5 Ok

Data

354 End data with <CR><LF>.<CR><LF>

subject: hello

i love you, oh my god! Why do i forget data

.

250 2.0.0 Ok: queued as E10601E09B1

quit