fix mailer generation to handle nested apps

in relation to #1011