A system and method for delivering a substance to a selected site in an alimentary canal of a human or animal includes an ingestible capsule. The capsule has a compartment for storing the substance a receiver suitable for receiving a signal through animal tissue a processor for storing a programmed set of instructions and an electronic power source. The system and method further has at least one transmitter, disposed on a medically relevant site on a body of the human or animal, for sending the signal to the receiver. The receiver includes a proximity based detector for measuring proximity of the receiver to the at least one transmitter, and the processor instructs a releasing device of the capsule to release the substance upon recognition of a pre-programmed pattern of signals.