Move the SMTP server setting into the send_email and quit once the email has been sent

Add debugging statement at the end