pre-mailer function