Q: Restricting users to specific domains in Postfix I have a user list and domain list. All users in user_list should only be able to send mail to domains listed in allow_urls.
user_list
/^user1@*/   OK
/^user2@*/   OK
/^user3@*/   OK
/.*@*/ REJECT 5.4.3. Sorry..

allow_urls
domain1.ru limited_class
domain2.ru limited_class

I have these lists defined in my main.cf, but it doesn't appear to be working. Any user can send to any domain.
smtpd_restriction_classes = limited_class
limited_class = check_sender_access regexp:/etc/postfix/border/user_list, reject
smtpd_sender_restrictions =  check_recipient_access hash:/etc/postfix/border/allow_urls

What am I doing wrong?

A: You did nothing wrong. The restrictions you configured is for incoming mail, where incoming means sent from "outside".
When you now say "every user can send..." then this is true. You can't restrict the destination address when sending to the outside world.
If this doesn't answer your question, then please rework on your question to express what you really mean. Or better: What do you want to achieve? You only say that it doesn't work without specifying what.

A: Right solution below
user_list
/^user1@*/   limited_class
/^user2@*/   limited_class
/^user3@*/   limited_class
/.*@*/ REJECT 5.4.3. Sorry..

allow_urls
domain1.ru OK
domain2.ru OK

main.cf
smtpd_restriction_classes = limited_class
limited_class =  check_recipient_access hash:/etc/postfix/border/allow_urls reject
smtpd_sender_restrictions = check_sender_access regexp:/etc/postfix/border/user_list 

