Why does sending an email message from PowerShell with the Send-MailMessage command using the flag -Port 587 produce an error.
Command:
Send-Mailmessage -smtpServer mail.server.com -Port 587 -from "[email protected]" -to "[email protected]" -subject "Test" -body "Test" Error Message:
Send-Mailmessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first
The PowerShell documentation says adding -UseSSL should specify that a STARTTLS command be sent -, but even adding this flag may not resolve your issues.
Command:
Send-Mailmessage -smtpServer mail.server.com -Port 587 -UseSsl -from "[email protected]" -to "[email protected]" -subject "Test" -body "Test" Eror message:
Send-Mailmessage : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.