complete gen_email script