If you list some okaddr's, ifvalidto will use them in place of $RECIPIENT. It exits 99 if none of them are listed in any recipients header fields.
For example, you can put
|ifvalidto
|./Maildir/
into your .qmail file to discard further processing and delivery of mails with a SMTP envelope address targeting you, but lacking a corresponding To or Cc information in the email headers. If ifvalidto is enhanced with the option -b it exits 100, thus you can enable a bounce mode:
|bouncesaying 'mail not delivered' except ifvalidto
|./Maildir/
Rather, you may wont to apply a particular spam-catch address:
|condredirect $LOCAL-spam except ifvalidto
|./Maildir/
Additionally, you can set a custom return code, provissioning ifvalidto with -r RC where RC is a none-negative return code.
NOTICE: In case you use a virtual domain you need to specify the unaltered recipient address upon call since RECIPIENT is the enhanced address including the virtual domain prefix.
WARNING: ifvalidto will potentially discard any mails originating from mailing lists. However, including your email address together with the usual 'To:' addresss of the mailing list allows to overcome this situation.