Which clouds can produce lighting and thunder?
Why are cumulus the only basic cloud type to favor lightning?
Because the speed of rising in the updraft is fundamental to lightning formation, as shown by this example plot from Total lightning activity as an indicator of updraft characteristics by Deierling and Petersen:



The faster the air rises, the more lightning in makes.  Only rapid updrafts can separate charges fast enough to overcome dissipation and build up the hundreds of millions of Volts (related ESE question) needed for lightning.  Out of the three standard cloud categories, only cumulus involves significant vertical motion.



Other cloud types?
First off, nearby clouds of other types can mask the cumulus structure responsible for the lightning.  Very commonly in strong storm environments, the broad widespread rising motion, especially near the warm front, can cause a thick low-level stratus deck to form.  And sometimes, in situations where dynamic forcing is dominant (such as with upper-level storm systems), or where storms move into a new environments (such as lake effect snow storms), fog can be thick, such that basically nothing can be seen!  So in those situations, its hard to truly attribute the lightning to the cumulonimbus, despite that being the cause.

Plus, full storm cells often develop fairly complex structures:

(Wikipedia, credit Kelvinsong)

Due to their shape and motions, some parts of storms might reasonably be categorized as stratus or altostratus, though they stem from a larger (past or present) cumulonimbus structure. These stratus-like components include arcus, incus, and velum.  And mammatus clouds that can occur as part of strong storms are actually a unique example of clouds with sinking air.  Even though air in these regions isn't rising much, leftover charge from nearby (or past) updrafts can still bring about lightning.  Anvil crawlers are a common lightning seen in the fairly flat upper regions of storms.  

Also, while more precise cloud classifications do now set the stages of growing thunderstorms clouds into the cumulonimbus genus, the nimbus prefix classically meant precipitating (raining/hailing/snowing).  Precipitation reaching the ground is not an absolute requirement for a storm cloud to produce lightning.  So in a loose sense, a cloud doesn't truly have to be a cumulonimbus, at least historically.

And of course, as it can do with just about any non-insulating material, lightning can pass through inactive clouds on the journey to the ground.

But while these situations may technically satisfy your search for lightning in other clouds types, you're fundamentally right, standard lightning generally derives from cumuloform cloud origins.