mail function complete - templates required