moved email server initialization to after the necessary variables are declared