beginning of email sending
huge refactor