I guess it's for a classic (wired) telephone. In this case you need a DTMF receiver (MT8870 or other), a microcontroller (AVR/PIC/8051...), a transistor and a relay.
The relay contacts should be connected in series with the telephone.
When the number is dialed, the uC reads the DTMF receiver and if the number it's not accepted, it will activate the relay and disconnect the telephone. This has the same effect like putting the receiver on hook and abandoning the call. After this, everything is reseted to the initial state.
In some countries it's illegal to connect homemade circuits to the public telephone system.