0

I have an application that worked perfectly until this Saturday. Every time I try send an email I receive the error "ExtendedSocketException: Connection refused [::ffff:xxx.xxx.xxx.xxxx]:25". I tried with 465 port but no solve the problem and it's show the error IOException: Unable to read data from the transport connection: The connection was closed.

The account email that I use in this app I use in my smartphone too and yesterday the I lost the connection with server. I contacted my provider and after remove the account and configured its started working again.

In the app I have this code

SmtpClient smtp = new SmtpClient("mail.yyyy.com", 465);
        smtp.EnableSsl = true;
        smtp.Credentials = new NetworkCredential("noreply@yyyy.com", "xxxxx");
        MailAddress from = new MailAddress("noreply@yyyy.com", "yyyy - NoReply");
        MailAddress to = new MailAddress(mail);
        MailMessage mailMessage = new MailMessage(from, to);
        mailMessage.Subject = subject;
        mailMessage.IsBodyHtml = true;
        reader = new StreamReader("wwwroot/templates/emails/comment-company.htm");
        body = reader.ReadToEnd();
        body = body.Replace("{url}", url);
        body = body.Replace("{company}", name);
        mailMessage.Body = body;
        smtp.Send(mailMessage);

Anyone have an idea what I can do to solve this?

1 Answers1

0

Try port 587 instead of 465. Port 465 is technically deprecated.

Ramin Azali
  • 198
  • 11
  • Thanks man, after change the port I received the error in certificate validation. I will send to provider solve this. – Diogo Lamego Aug 04 '21 at 08:45
  • i think i know the way for it you can go to your Gmail (Sender) , i dont remmember for sure but you should give some access in your gmail, after that you can send your emails (Sorry For Bad English) – Ramin Azali Aug 04 '21 at 08:54