mailer function working properly with attachment