///<inheritdoc/> public async Task <(SendMailResult, Guid)> SendMail(IMessage message, IEmailAddress redirectTo) { Guid requestId = await _mailRepository.SaveRequestAsync(message); IMessageHandle msgToSend; if (_isProduction) { msgToSend = new Message ( message.Subject, message.Content, message.From, message.ReplyTo, message.To.ToList(), message.Cc.ToList(), message.Bcc.ToList(), message.Files.ToList(), message.EnableHtml ); } else { if (string.IsNullOrWhiteSpace((redirectTo ?? _redirectOptions).Email)) { throw new ArgumentNullException("RedirectTo options parameters is not defined in application settings"); } msgToSend = new Message ( message.Subject, message.Content, message.From, message.ReplyTo, new List <IEmailAddress>() { redirectTo ?? _redirectOptions }, null, null, message.Files.ToList(), message.EnableHtml ); } if (message.Headers.Count > 0) { foreach (KeyValuePair <string, string> header in message.Headers) { msgToSend.AddHeader(header.Key, header.Value); } } SendMailResult mailResult = await _sender.SendMailAsync(msgToSend); return(mailResult, requestId); }