A bad smell that comes from the toilet, including a smell that only comes out when you flush the toilet, may be caused by a bad seal around the base of the toilet or other potential problems. If the seal is the source of the leak, the toilet was not installed correctly and must be reinstalled.
Function of the Seal
The seal on the bottom of the toilet is made up of two parts. The wax ring sits against the bottom of the toilet, surrounding its drain opening, as well as around the opening of the drainpipe in the bathroom's floor. The flange sits under the wax ring and attaches to the bathroom floor itself with several screws which reach into the bathroom's subfloor. When you tighten the nuts on the bolts, which anchor into the flange, the toilet should not move at all. The seal will not allow water or any sewer smells to escape either.
The trap is the curved portion of the toilet's drain, which you can see on the side of the bowl. The trap is designed to keep a certain quantity of water trapped inside at all times. The water keeps sewer gasses or smells from coming up through the drain in the floor and out of the toilet's bowl. A leaking seal will allow water to escape the toilet's trap, enabling the smells to come through the trap. These gasses not only smell bad, but they can contain methane, which is flammable.
Blocked Vent Pipe
Every plumbing fixture in a home depends on a vent pipe to operate correctly. The vents do not let air out of the plumbing system but rather draw in air that is lost when water is washed down a drain. When the vent pipe is clogged with a bird's nest or other obstruction, the toilet's water level can drop to the point that sewer gasses pass through the trap uninhibited.
Solution to Lack of Use
Toilets that are not used very often should be refilled with water every two weeks, helping to prevent sewer gasses from coming through the trap as water evaporates out. To further help slow the evaporation in the toilets' trap, pour 118ml. of mineral oil down the toilet's drain, allowing it to settle into the trap's curves. Mineral oil evaporates slower than water and so will block sewer gasses from passing through the trap.