“Unable to read data from the transport connection: net_io_connectionclosed.” - Windows Vista Business and SMTP

后端 未结 11 1553
北海茫月
北海茫月 2021-02-06 21:37

Unable to test sending email from .NET code in Windows Vista Business.

I am writing code which I will migrate to an SSIS Package once it its proven. The code is to send

11条回答
  •  生来不讨喜
    2021-02-06 22:39

    There are several things that can cause this problem, and here are some of the things that I've found. Questions: You mention "Exchange" -- Is this an exchange server? Does the host require authentication (maybe you need to add authentication to the client)? What I would try doing first is assigning the host to the static IP address instead of the host name to see if that works first. If it does then it's most likely a problem with the DNS mapping.

    If you are running your exchange server with Virtualization, you need to configure the SmtpClient to the host IP of the Virtual Server, not the physical hosting server name or IP. Right click on Default SMTP virtual server, select Properties, then go to Access tab, click Relay then add the IP address of the computer that send SMTP request to the SMTP server. (ASP.net site)

    If this doesn't work, it's because the server is blocking you from sending SMTP packets. You need to make sure to add the box you are sending the SMTP messages from to the SMTP server. This is done through IIS's authentication tab.

    I would also like to point out that you should dispose the mail client, or use the client in a "using" statement. This will make sure that the "QUIT" is sent to the server and gracefully close the connection.

    using(SmtpClient smtp = new SmtpClient())
    {
        smtp.Host = "emailservername";
        smtp.Port = 25;
        smtp.UseDefaultCredentials = true;
        smtp.Send(mail)
    }
    

提交回复
热议问题