mailinfo: factor out some repeated header handling