To add to @ΤΖΩΤΖΙΟΥ's answer, if you need to check a specific condition and then return a custom message, you can create an smtpd_restriction_classes that specify the action you want to do once the condition has been verified.
Use case: Provide a custom rejection message to suspended accounts
As already mentioned, create the custom message file (e.g. /etc/postfix/custom_message) but with a "catch-all" regular expression:
/.*/ REJECT Sorry, your account has been suspended
Edit the /etc/postfix/main.cf file and add the following line before any restriction lines (like smtpd_recipient_restrictions):
smtpd_restriction_classes = reject_suspended_accounts_with_custom_msg
reject_suspended_accounts_with_custom_msg = regexp:/etc/postfix/custom_message
In the map file where you select the suspended virtual mailboxes (e.g. etc/postfix/suspended-map.cf) put the following query (example with MySQL, provided there is an account_has_been_suspended column to identify such accounts):
...
query = SELECT 'reject_suspended_accounts_with_custom_msg' FROM virtual_users WHERE email_address='%s' AND account_has_been_suspended=1
Finally, in the proper restriction parameter (either smtpd_sender_restrictions or smtpd_recipient_restrictions) add the check:
smtpd_recipient_restrictions = check_recipient_access mysql:/etc/postfix/suspended-map.cf
In this way, a virtual mailbox that has been marked as "suspended" in the database, will receive a custom rejection message.