The addition of amines to aldehyde and ketones results in the formation of imines and enamines. Water is also produced as a byproduct. Imines will form when the amine is primary, while enamines will form with secondary amines provided the aldehyde/ketone has alpha (α) protons.
Here are the overall reaction for both imine and enamine formation.
These reaction is catalyzed by acid and is often driven to completion by removing water. There is an optimal amount of acid required, too much or too little and the reaction will slow down. Other amine "like" nucleophiles (hydrazines and hydroxylamine) will also add and follow similar mechanisms.
Amines are great nucleophiles. The amine adds to the aldehyde/ketone in the first step. The resulting tetrahedral intermediate undergoes a proton transfer (denoted PT), transferring a proton from the protonated amine to the alkoxide. This produces the carbinolamine intermediate. It's analogous to a hemiacetal in the addition of alcohols to aldehydes/ketones. The carbinolamine hydroxyl group must be protonated, activating it to be expelled as water. This is the step requiring acid. Once the water is expelled a protonated imine is formed (iminium ion). Subsequent deprotonation by water (or amine or carbonyl O or whatever - who knows - your guess is as good as mine) results in the imine.
Why is optimal pH required?
If too much acid is used (low pH) then the amine becomes protonated and is no longer nucleophilic.
If there is not enough acid (high pH) then the carbinolamine intermediate can not be protonated and subsequently eliminate water.
Examples of Reactions (Imine Formation)