Send-MailMessage failing

Causemaker, Andi 0 Reputation points
2024-03-26T19:21:02.2366667+00:00

I am trying to use "Send-MailMessage" to test my smtp connectivity to an SMTP server. The 'client' in question is Windows Server 2022 Datacenter. I am getting the error message:

Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed.
At line:1 char:1
+ Send-MailMessage -from <******@domain.com> -to <******@domain.com> ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

I have verified that the traffic is NOT being blocked by our firewall. Other servers in the same subnet are able to send mail using the same SMTP host (exact same command) without any error.

Is there some configuration on the client that I'm missing? or is there something on the server that could be blocking a single IP/host from being able to send?

Windows for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2024-03-26T19:40:07.7933333+00:00

    Can we assume that you're using SSL? If that's the case it may be that the client is using an unsupported version of TLS.

    Try this: [System.Net.ServicePointManager]::SecurityProtocol = 'TLS12' before the Send-MailMessage.

    If that doesn't work, try "TLS13".

    Also, are you authenticating (i.e., providing a credential) with Send-MailMessage? Are you using a client (587) or server port (25)?

    What you've missed is providing a code snippet that details your usage of the Send-MailMessage cmdlet. Without that one can only guess at the source of your problem.

    0 comments No comments

  2. Causemaker, Andi 0 Reputation points
    2024-03-26T19:51:32.8433333+00:00

    Hello, sorry I should have provided more details.

    Nope, no SSL, No credentials/authentication. Just plain SMTP on port 25. It works from every other server I've tested it from but this ONE.

    Here's the command I'm using. I can literally copy/paste this same command on multiple servers, and all will send the message successfully except this one server:

    Send-MailMessage -from ******@domain.com -to ******@domain.com -subject "smtp test" -SmtpServer smtp.domain.com


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.