handle different mail structures