Moved functions and variables to top, Created if/else statement to send mail or deliver error message
Added Composer and Mailgun services