mail function implemented with smtp config