made some changes to mailing system due to PG Db change