Пример #1
0
        /// <summary>
        /// Send an email asynchronously, using an <see cref="SmtpClient"/>.
        /// </summary>
        /// <param name="email">The email to send.</param>
        /// <returns>A <see cref="Task"/> that completes once the email has been sent.</returns>
        public async Task SendAsync(MimeMessage mailMessage)
        {
            using (var smtp = await options.PrepareSmtpClientAsync())
            {
                this.logger.LogDebug($"Smtp created: host: {options.Host}, port: {options.Port}, securiry: {options.SecurityOption}");
                this.logger.LogInformation($"Smtp send email from {mailMessage.From} to {mailMessage.To}");
                await smtp.SendAsync(mailMessage);

                await smtp.DisconnectAsync(true);
            }
        }