modified sending mail function to handle multiple recipients