completes code for mailer

needs to be tested