In principle, one can replace a good leaving group with ammonia or amines leading to a more complex amine or ammonium salt.
However such reaction don't proceed with good yields save in exceptional cases.
The reaction is successful only if the resulting amine is converted into ammonium
salt - the nitrogen thus losing its nucleophilicity - or if it is intramolecularly carried out .
Let me insist!!!
This simple method is not good to prepare amines.
IMPORTANT alternate method:
To carry out the reaction with a function precursor of the amine group.
The amine group remains LATENT until the appropriate step where it is released.
Siegmund Gabriel (7 November 1851 – 22 March 1924) was a German chemist.
How can one get the phthalimide?
There are other precursor functions of amines: azides and cyanides.
Once the substitution has been effected, the reduction of the azide or nitrile functions allows us the production of amines.
Please, be aware that in the case of cyanide the resulting amine has an additional carbon atom.