I use the following code snippet to send a message, why does the program hang when sending a message? What did I do wrong?

public static void SendMail() { System.Net.NetworkCredential crdSupport = new System.Net.NetworkCredential("easy_send_mail", "password"); SmtpClient smtpConfirmation = new SmtpClient("smtp.mail.ru", 465); smtpConfirmation.UseDefaultCredentials = true; smtpConfirmation.Credentials = crdSupport; MailMessage mmConfirmation = new MailMessage(); mmConfirmation.From = new MailAddress("easy_send_mail@mail.ru", "EasySendMail"); mmConfirmation.To.Add("test@mail.ru"); mmConfirmation.Subject = "EasySendMail test subject"; mmConfirmation.Body = "EasySendMail test body"; smtpConfirmation.Send(mmConfirmation); } 
  • Read about async/await ... - EvgeniyZ
  • Do you have access to mail.ru? - Zergatul
  • Well, I registered a new mailbox easy_send_mail and instead of Password I wrote a password for it - Vurvu
  • one
    This is understandable, but does your program have access to smtp.mail.ru on port 465? Try creating a TcpClient and see if you can successfully connect. - Zergatul

0