Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure sending mail. #368

Open
kulame opened this issue Mar 31, 2023 · 0 comments
Open

Failure sending mail. #368

kulame opened this issue Mar 31, 2023 · 0 comments

Comments

@kulame
Copy link

kulame commented Mar 31, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant