Refactor variable name $f as it throws "Illegal string offset 'name'"

This also resolves the misplacement of attached inline images in html emails