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

后端 未结 11 1486
北海茫月
北海茫月 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:29

    I had the same issue since I had multiple IP on my server (Virtual Servers) and my host was pointing to localhost while my SMTP Virtual Server was assigned to one particular IP:

     <smtp deliveryMethod="Network">
           <network host="localhost" port="25" defaultCredentials="false"/>
     </smtp>
    

    There are 2 solutions for this:

    1. Change your code and set host to the particular IP that is being used by SMTP Virtual Server instead of localhost.
    2. Change SMTP Virtual Server IP to All Unassigned

    To see/change SMTP Virtual Server IP: Right click on Default SMTP virtual server, select Properties, on General tab change/see IP address.

    Hope this saves someone's day with the same issue.

    0 讨论(0)
  • 2021-02-06 22:31

    I developed a Windows Service application in VB using .NET Framework v4.5 and recently ran into this issue.

    First, a little background - I ran into the OP's error after trying to deal with the error "Service not available, closing transmission channel. The server response was: Error: too many messages in one session" which was resolved by calling the Dispose method on the SmtpClient object after each email sent. Just to be ultra safe, I also called Dispose on the MailMessage object.

    Okay, so now the 'too many messages in one session' issue is resolved but now I occasionally got the 'Unable to read data from the transport connection: net_io_connectionclosed' error. Awesome. Turns out I had not implemented my email class consistently - in one instance, it was being disposed of while in the other it was not.

    Here's an example of what resolved both issues for me (it's in VB but you get the idea):

    With New clsEmail(True)
        With .Message
            .To.Add("user@domain.com")
            .Subject = msgSubject
            .Body = msgContents
        End With
    
        .Server.Send(.Message)
        .Server.Dispose()
        .Message.Dispose()
    End With
    

    My email class has, among other things, has 2 properties - Message (System.Net.Mail.MailMessage) and Server (System.Net.Mail.SmtpClient) which is what's being disposed in this example.

    I haven't had a single problem after hundreds of emails once every single instance that sends email in my service was implemented in this way.

    0 讨论(0)
  • 2021-02-06 22:34

    I have found that the Vista Business OS does not come with IIS SMTP. I suspect this is the missing piece of the puzzle. Has anyone had any luck with this issue?

    0 讨论(0)
  • 2021-02-06 22:37

    Is your code incompleted.Dash is correct in identifying it.Other then that check smtp component is installed or not check link text

    0 讨论(0)
  • 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)
    }
    
    0 讨论(0)
提交回复
热议问题