Imported Pmail code