1

I am trying to send confirm mail using smtp. Here is my code:

        var client = new SmtpClient
        {
            Host = "stmp.gmail.com",
            Port = 465,
            UseDefaultCredentials = false,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            Credentials = new NetworkCredential("email@gmail.com", "password"),
            EnableSsl = true,
        };
        var from = new MailAddress("email@gmail.com", "Confirm mail");
        var to = new MailAddress(message.Destination);

        var mail = new MailMessage(from, to)
        {
            Subject = message.Subject,
            Body = message.Body,
            IsBodyHtml = true,
        };

        client.Send(mail);

But I got an error: Failure sending mail. First I got an email from Google said that Google blocked signing in from less secure app and "Google will continue to block sign-in attempts from the app you're using because it has known security problems or is out of date. You can continue to use this app by allowing access to less secure apps, but this may leave your account vulnerable.". After that I have turned on Access for less secure apps but still got the same error.

Anyone have the same problem?

0 Answers0