locked
Does Blazor Server support SMTP? RRS feed

  • Question

  • User-1490918605 posted

    To send a conformation mail to my users I use System.Net.Mail.SmtpClient.

    While debugging this works fine but after I published my project to IIS on the same machine the emails are never received and neither is there any error message.

    So does Blazor Server support SMTP or need I do something else?

    Thanks in advance.

    Sunday, August 9, 2020 5:49 AM

All replies

  • User-821857111 posted

    So does Blazor Server support SMTP
    Yes.

    Without seeing the code you are using, it is impossible to guess why this doesn't work for you in production.

    Sunday, August 9, 2020 7:24 AM
  • User-1490918605 posted

    This code works in debug mode but not after published to IIS on the same machine:

    private string Send_Email(string ToMailAddress)
    {
    string Msg = "Ok";
    try
    {
    using SmtpClient smtp = new SmtpClient();
    {
    smtp.Port = 587;
    smtp.Host = "smtp.live.com";
    smtp.EnableSsl = true;
    smtp.UseDefaultCredentials = false;
    smtp.Credentials = new NetworkCredential("...2020@outlook.com", ".....");
    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

    using MailMessage message = new MailMessage();
    {
    message.From = new MailAddress("deedelta2020@outlook.com");
    message.To.Add(new MailAddress(ToMailAddress));
    message.Subject = "DeeDelta: Confirm your email account.";
    message.IsBodyHtml = true; //to make message body as html
    message.Body = "Thank you.";
    smtp.Send(message);
    }
    }
    }
    catch (Exception ex)
    {
    return ex.Message;
    }

    return Msg;
    }

    Sunday, August 9, 2020 8:26 AM