Using constants
Caching mail variables
Added try-catch