updated some code related to external database mailer