Open kulame opened 1 year ago
I am trying to send an email to Feishu email server. my code is
builder.Services.AddFluentEmail(smtpUsername).AddRazorRenderer().AddSmtpSender(new SmtpClient() { Host = smtpHost, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, Port = smtpPort, UseDefaultCredentials = true, Credentials = new NetworkCredential(smtpUsername, smtpPassword) }); Task.Run(async () => { using (IServiceScope scope = _factory.CreateScope()) { _logger.LogInformation($"Sending email to {user.Name}"); var _fluentEmail = scope.ServiceProvider.GetRequiredService<IFluentEmail>(); _logger.LogInformation("got email service"); try { await _fluentEmail.To(user.Email) .Body("The body").SendAsync(); _logger.LogInformation("Email sent"); } catch (Exception ex) { _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); _logger.LogError(ex.) } } });
it raise error
info: SocialApi.Services.TaskService[0] Failure sending mail. fail: SocialApi.Services.TaskService[0] at FluentEmail.Smtp.SendMailEx.SendMailExImplAsync(SmtpClient client, MailMessage message, CancellationToken token) at FluentEmail.Smtp.SmtpSender.SendAsync(IFluentEmail email, Nullable`1 token) at SocialApi.Services.TaskService.<>c__DisplayClass4_0.<<SendEmail>b__0>d.MoveNext() in /srv/social/SocialApi/src/Services/TaskService.cs:line 44
what's wrong with this code?
I am trying to send an email to Feishu email server. my code is
it raise error
what's wrong with this code?